It is possible to shoot a gun underwater; because cartridges are sealed and so powder remains dry.

Now the problem that may arise is all about a ratio speed of the bullet/caliber. The faster a bullet is, the more it will meet resistance owing to the density of water which varies according to the depth under which you fire the gun. A small caliber such as .223 (the M16 or M4) fired underwater is likely to damage the gun as its speed is very fast (about 2750 feet per sec) and its diameter very small (a quarter of an inch).

Water pressure and density will offer so much pressure, and so resistance, when compared to this of ambient air, that the pressure inside the barrel will rise tremendously to the point of blowing up the gun or literally inflating the barrel; thus making the gun irremediably damaged.

So, firing a gun underwater as long as its caliber is not too small, and its bullet speed not too fast, is possible. Bullet speed ranging from 600 to 1000 feet per second, for a caliber such as 38 to 50 are a good pick.

Now, a nother problem is the water pressure which tremendously increases as we go deeper in it, thus changing a gun's performances to a considerable extent.

As exemple, a .45 Auto bullet shot under 3 feet of depth is likely to have maximum range of 25 to 50 meters. The same shot under 150 feet of depth is likely to have maximum range of 1 to 5 meters!

This change in performances may be considerable, as you can see.

The use of a silencer or noise reducer would prove to be of little avail underwater, as such device has been conceived to work properly in ambient atmospher filled with 1 atmosphere of air pressure.

To work properly, a gun's silencer must be fired with bullets whose speed are inferior to this of the sound in ambient air, which is of about 960 feet per second. If the bullet speed is in excess of this speed, then the silencer will not reduce the sound at all, exactly as if no silencer was mounted on this gun...

However, I confess that I would be curious to see what would happen when a gun with silencer is fired underwater; as the speed of sound is considerably faster in a middle filled with water than in air.

Gun especially conceived to fire underwater exist, indeed. The Russian made some for special operations purpose. See the link I provide you with below.