Serious reply:
I understand your concern, but remember: one less party member means the rest will have to soak all the incoming damage without the benefit of the gunsmith's AC or HP.
The other players should quickly realize this. If they're complete newbies, have a NPC point it out next time they fight where there are witnesses.
After that you just wait. The other players should start demanding the gunsmith do their part in defense and not just offense, or maybe he shouldn't get a full share of the loot... or even be booted from the party.
But that's not all - equally important is talking to the player.
If you realize he's just doing this because he's new and doesn't realize teamwork includes defense as well as offense, he should learn soon enough per the above. At the other end of the scale, if the player is more experienced, and should have known better; maybe he's only interested in his own personal power trip, you'll have to be blunt: that's not how you want him to act, and ultimately change behavior (maybe roll up a melee fighter?) or leave the game.
What I don't recommend is the indirect (even passive-agressive) method of popping random monsters or something else in game: this is an out-of-game issue that needs an out-of-game solution.
By that I mean that in the context of the game, his actions are perfectly reasonable. So don't punish perfectly reasonable actions with random monsters. In game, the only recourse is for the rest of the party to ask the gunsmith to be there for monsters to beat on, since this means less risk somebody else will die. Safety in numbers and all that.
This confuses me. Why would the team be mad that the sniper is sniping? When I'm a player, if the DM had an NPC point out that the sniper doesn't seem to be taking much risk of getting hit by the enemy, I'd just say, "Yeah, and good thing, too. That's my job. His job is kill guys without me having to worry about needing to keep him safe." or something along those lines. Just like with a sneak that has ways of being hidden nearly all the time. Great. That means they also get advantage a lot, so their attacks land a lot, so the enemies go down faster. Sounds good. Either way, they are absolutely still contributing just as much to the team's success as they tankey fighter.
And then on the other end, you're telling OP not to "punish" the player with monsters, as if all the bad guys are just...what, always in a clump, even though the PC's aren't? How does that make sense?
[MENTION=6806492]randrak[/MENTION] Of course there will occasionally be threats to the sniper, in the form of :
flanking enemies
enemy snipers/spell-snipers
really fast/teleporting/flying enemies that the PC can't outrun easily to get out to sniper range
and obstacles to actually doing the thing, like;
terrain that makes it hard to get shots that far out without using whole rounds to get high ground
Indoor fights
Circumstances outside the fight which make it a bad idea to separate from the party, including a running clock. Having to catch back up with the party after the fight ends wastes time if there is some kind of reason they have to get somewhere fast.
None of those should be arbitrarily applied as punishment, they are just logical circumstances that should arise
sometimes.
Especially the enemies that have range, can run fast/teleport/fly. If you normally sometimes have waves of enemies, sometimes they should be encountered by a character that moves far away from the party. If not, I wouldn't really use that option.
In the end, determine why this is a problem for your table, figure out if you can adjust your approach to accommodate a pretty reasonable in-game and mechanical decision, and if not, talk to the player about it.