Just for fun, I will treat this as a legitimate query. First, no conventional gun will work normally under water or with water in the barrel. At best the gun simply blows the water out slowing the bullet to a non-lethal speed; at worst the water constitutes an excessive projectile mass and the barrel blows or bulges.
If that situation were encountered, the best practice would be to have the gun in a water-proof container (aka, a "baggie") and remove it on exit from the water or simply shoot through it. In the latter case, the baggie might hang up an auto pistol, but you should get off at least one shot.
FWIW, "underwater guns" actually "fire" darts or arrow type projectiles using CO2 or compressed air as a propellant, not gun powder. Normal bullets, even high power bullets (like a .50 bullet fired from an aircraft) will penetrate water only a few feet and will not be dangerous for most of the penetration.
Jim