This information can only be retrived from a SerializedProperty. The default inspector uses a PropertyField for every field. Inside PropertyField you can find this code which sets the bold state for this property according to the “prefabOverride” value of the serialized property:
If you need to develop some advanced editor GUI stuff, i recommend to use ILSpy on the UnityEditor.dll (and UnityEngine.dll) to see how the GUI functions are implemented.
If you mark your object after altering it with EditorUtility.SetDirty(arg), it will be stored properly. We had the same problem in our project, causing custom components to replace their values with prefab values at random.
I don’t know yet, how to know that the value should be bold, so the change is not visible in my custom component editor, but in the debug editor, the value is written with a bold font.
If someone wants to make a custom “boldable-on-override” property drawer (as I do), he can place his GUI code between BeginProperty/EndProperty pair. This way you will also get the standart “Revert Value to Prefab” menu when right-clicking.
EditorGUI.BeginProperty(position, label, property);
/// Your GUI code here...
EditorGUI.EndProperty();