Well, that depends on what version of minecraft you're using. If it's bedrock I'm pretty sure you use this command: /give <target> <item> 1 0 {"item lock": {"mode": "lock_in_slot"}}
I believe in java you have to use "/item replace" , I'm not sure what the parameters are for it, though.