Using this command
tank lockTurret [[0,0], true];
on M2A1 for example will remove enter commander action from outside the tank but when inside the option to switch to commander is still available and cannot be removed no matter what.
Same happens with
tank lockTurret [[0], true];
for gunner position. It is disabled from outside but permanently available from inside. lockDriver and lockCargo work for both.