So what possible morality can you build into the gun to prevent immoral use?
You can’t build morality into it, as I said. You can build functionality into it that makes immmoral use harder.
I can e.g.
limit the rounds per minute that can be fired
limit the type of ammunition that can be used
make it easier to determine which weapon was used to fire a shot
make it easier to detect the weapon before it is used
etc. etc.
Society considers e.g hunting a moral use of weapons, while killing people usually isn’t.
So banning ceramic, unmarked, silenced, full-automatic weapons firing armor-piercing bullets can certainly be an effective way of reducing the immoral use of a weapon.