Yes. It is absolutely possible to fire a gun in space,
Unlike the old days, modern ammunition is not dependent on the the atmospheric oxygen to create the chemical reaction that results in the discharge of a round from a gun. The oxidizing agents are present both in the primer and the propellant of the ammunition.
This would mean that the gun can also be fired underwater but it won't be very effective. On the other hand, firing a bullet while in space is also a totally different ball game than firing it normally on the surface of the earth. Here are the differences:
1. You won't hear the gunshot because of the vacuum of the space
2. The recoil of the gun would push you and will permanently change the trajectory of your motion in space, On earth the recoil is countered by the frictional forces between your foot and the ground.
3. The smoke leaving the gun barrel would expand like a sphere from the muzzle (unlike the earth, where the smoke leaves the muzzle as a trail)