LayerLocked(), added line layer.SetPersistentLocking(True) for it to work properly. Without this line when locking a layer with the function LayerLocked(ln, locked=True), goes into the same lock state as if it would be unlocked but have a locked parent layer (the half lock symbol). This is in contrast to how the Rhino UI behaves. It is a similar problem  that I encountered with LayerVisible(). For LayerVisible() the persistent function had to be called with False, for LayerLocked() it had to be called with true.