After the @DMGregory♦ comment I come across [this](https://docs.unity3d.com/ScriptReference/EditorUtility.SetDirty.html) documentation.

So, to have the changes made through the editor API serialized correctly I did change this way:

    Undo.RecordObject(gameObjectInScene, "Set reference for itsField.");
    gameObjectInScene.itsField = theFieldValue;
    PrefabUtility.RecordPrefabInstancePropertyModifications(gameObjectInScene);