you can lock gameobject from being edited or moved all you need to do is to assign layer to the gameobject and at the top right corner you can find the layer dropdown , on opening the dropdown you can see the small lock icon with which you can lock the layer from edited in the scene view
using UnityEditor;
using UnityEngine;
public static class Readonly
{
[MenuItem("GameObject/Set readonly")]
public static void SetReadonly()
{
foreach (var o in Selection.objects)
{
o.hideFlags = HideFlags.NotEditable;
}
}
[MenuItem("GameObject/Set writable")]
public static void SetWritable()
{
foreach (var o in Selection.objects)
{
o.hideFlags = HideFlags.None;
}
}
}