@RafalF, you can only lock the object or the layer. The Color of locked objects or objects on locked layers depends on the display mode setting for locked object usage:
Great. It’s working like I wanted. Do you know how change that property using programming? I found only how to change locked color…
Rhino.ApplicationSettings.AppearanceSettings.LockedObjectColor = Color.WhiteSmoke;
the display mode settings are not changeable via RhinoCommon as far as i understand. But you could create your own displaymode with the required settings for locked object color usage and assign this display mode to your object using a scripted command of _SetObjectDisplayMode.
The setting to control the locked object color you’ve found is the only one i know. It works application wide, so when a display mode is set to “Use Application Settings” for the “Locked Objects / Locked object usage” dropdown, then this color is used.
The setting to change for the specific display mode is not exposed yet in RhinoCommon as far as i see. There are a few other settings shown here… i see nothing to change the locked object color usage.
My suggestion would be to manually create your own display mode having the setting changed already, then try to apply this mode to the objects programmatically.