Disclaimer: you should never play or experiment with guns or firearms of any kind, nor use them to harm anyone, nor for any destructive purpose. This article is actually about orbital mechanics, not guns.
What if you could shoot a gun straight and true, so that the bullet traveled directly forward from your chest at high velocity, went all the way around the earth, and hit you in the back? That might be the only way to shoot yourself in the back.
Well, orbital velocity on earth is 17,500 mph, and no gun is that powerful. Military railguns have reached 5,370 mph, which is pretty impressive, but still not fast enough to achieve orbit. And then there's that pesky air, as thick as syrup at hypersonic speeds. In just a couple miles the projectile is subsonic. So that's just not going to work. If you are determined to shoot yourself in the back, then you better go to the moon.
There's no air on the moon, but that's a bigger problem for you than for your gun. You could use one of the aforementioned rail guns, but those are large and bulky, and they just don't have the satisfying feel of a rifle in your arms. The White Album reminds us, "happiness is a warm gun". So let's stay with traditional firearms. Fortunately for us, gun powder (and its chemical cousins) includes its own oxidizer, e.g. potassium nitrate. Air is not required to drive the chemical reaction behind the bullet. In fact, burning in air would be much too slow for an effective explosion. The powder must include both fuel and oxidizer intermixed. Thus a gun, perhaps with minor modifications, should work on the moon.
How fast does a bullet have to travel to achieve lunar orbit? The moon has 27.3% of the earth's diameter, and 1.23% of its mass. Following the universal law of gravitation, gravity on the moon is 0.0123 / 0.2732 G, or one sixth the gravity of earth. A 186 pound man only weighs 31 pounds on the moon. So gravitational acceleration is reduced by a factor of 6, and circular acceleration, given by the formula v2/r, must balance. Start with 17,500 mph, orbital velocity here on earth, and multiply v by the square root of 27.3% to compensate for the moon's smaller radius. Then multiply by the square root of 1/6 to adjust for the lower gravity. The new velocity is 21.3% of 17,500 mph, or 3,720 mph. This is at the high end of modern rifles. The .220 Swift realizes a muzzle velocity of 2,660 mph, 71% of what we need, and that is a street weapon, easily acquired by the general public. It is used to hunt small game from a great distance, where accuracy is vital. No room for a bullet drop here. An experienced hunter can hit a groundhog at 375 yards. With this in mind, I will assume that the military possesses, or could easily build, a portable rifle with the necessary power.
You are standing on the moon with an adequate gun. The bullet will trace a circle around the moon, and hit you in the back at a speed of 3,720 mph, in just under two hours. If you want to avoid bodily injury, then just step out of the way. Of course the bullet will continue to circle the moon until it hits something or someone. If you're a Myth Buster, then step out of the way and put Buster in your place. Sorry Buster! But there's a catch. What if your aim isn't level and true? What if the gun is tilted down just a fraction of a degree? The bullet will crash into the lunar surface within a couple hundred miles of launch. The circle that is the bullet's trajectory tips down and touches the moon. Similarly, if the barrel is tipped up just a fraction of a degree, the circle tips back and touches the moon behind you. The bullet hits the ground 200 miles behind you and never reaches your location. So the gun has to be impossibly level. The solution is to use a gun with just a bit more power. This pushes the circular orbit into an ellipse. You stand at the low point of the ellipse, just a couple meters off the ground, while the high point of the ellipse, on the opposite side of the moon, is 100 miles up. You only need a modest increase in muzzle velocity to produce the desired ellipse, 3,850 mph should do the trick. Now you have some breathing room. The gun doesn't have to be spot-on level, and the bullet will even clear a lunar mountain range over the horizon that you hadn't anticipated. You don't have to be at the highest elevation along the bullet's trajectory, but neither can you stand in a crater, nor even a shallow depression. You should be at least at the top of a hill, the highest point within your ken.
The next problem : the moon moves. Specifically, it turns on its axis once every 27.3 days. The bullet leaves the gun and traces a circle around the moon, but in just a few seconds you are no longer standing under that circle. You have moved to the side. If you are near the equator, and you aim north, then you are moving perpendicular to the circle at 4.6 meters per second. You will be miles away by the time the bullet returns. One way around this is to stand at the equator and aim due east. The circle runs around the equator, and you're still standing on the equator when the bullet returns. But there are two problems with this plan. As mentioned above, the circle has to be an ellipse, and you were standing at its lowest point. After two hours you have moved forward along the path of the ellipse, and it is higher off the ground. The bullet sails harmlessly overhead. The second problem is one of precision. Just as the gun cannot be perfectly level, so it cannot aim perfectly due east. An arc second to the north or south will tilt the ellipse, and once you and the ellipse have diverged, the bullet will pass you by. No - the only place you can stand is the north pole. Fortunately, the north pole has some accommodating mountains, so this might work out. In contrast, the south polar region has many craters, and the precise south pole could be in permanent darkness.
If the moon were a perfect sphere of uniform density, and if you knew the precise location of the north pole, and if your aim was true and level, perhaps guided by some technology, we might declare "Mission accomplished!" Yes indeed, the bullet will return to you in 2 hours. But the moon is not a perfect sphere, and is not uniform in its composition. As the bullet flies down from the north pole headed south, it might pass a mountain on its right, or perhaps an unusually dense region of rock beneath the moon's surface. Either way the trajectory is bent ever so slightly. The ellipse tilts, and when the bullet returns, it passes a few meters to your left. Apollo 11 had to compensate for these gravitational perturbations. Even from 60 miles up, the effect is noticeable after a dozen orbits. In a very low orbit, just meters high at its perilune, the ellipse is probably bent after just one transit around the moon. It only has to move by a meter to miss you. Is there a longitude that runs perfectly between the mountains, wherein the ellipse would not be appreciably disturbed after one orbit? I doubt it, and if there was, it would once again require precise aim, neither an arc second to the left nor the right.
After all that work, I'm afraid it is not possible to shoot yourself in the back, even on the moon. That's ok; we all have better things to do in space. I sincerely hope people are back on the moon, and/or on Mars, within my lifetime.