I do not really play a lot of Mann vs Machine as Sniper but I decided to give it a try.
I am using the Urban Professional loadout with a strange ks Tribalmen's Shiv. What is my highest priority as a Sniper in mvm?
Note: I don't play a lot of MvM Sniper because I suck at Sniper... I mainly play Medic in MvM.
In MvM, your target order is really going to be the same regardless of class.
As a Sniper, you may also be useful in dealing with Spies that show up in some games.
Sniper sucks at dealing with tanks, so you may want to concentrate on keeping other enemies in check while your teammates deal with tanks.
One of your more useful upgrades as Sniper is explosive headshots. It can kills groups of smaller enemies.
Keep in mind that money gained from headshot kills is red and doesn't need to be collected... it exists solely to heal your team's Scout.
A lot of people believe Sniper in MvM is not viable to replace a demoman or another high DPS crowd controlling class. A good sniper in MvM can easily outshine these other classes.
As a Sniper you are a jack-of-all-trades. Supporting your team through mini-crits, slowing the enemies, taking out groups of enemies and guaranteeing money for your team. Every robot that gets finished off by a sniper or spy, the money dropped will have red money particles, and does not need to be recovered for it to be added to your overall money, meaning the only class that will benefit from that money is the scout, and his passive ability which grants him overheal from picking up money.
I'm not here to badmouth Demoman, there are plenty of situations where Demoman will outshine Sniper in crowd control and single-target damage output, but here are a few examples of Sniper being better than Demoman:
Three Giant Heavies being healed with 6 Uber Medics each. The Demo will need to set up traps for each pair, and will need to take longer to reload and fire, not to mention the potential of missing the kill with the explosives and how much ammo it is using to guarantee a destroyed uber bot. As a Sniper, all you have to do is target the Giant with a headshot, and you will most likely kill all the medics in one *explosive headshot zap. Proceeding to headshot the next two giants and then focusing down a giant, providing mini-crits and slow with your jarate.
Giant Scouts can zoom past your team before you knew what happened. Arguably a good demo can sticky-jump back to base to take care of it before it caps a gate/plants the bomb, but demoman hasn't got anything that can slow the enemy down, or have consistent damage at range.
Multiple groups of small enemies can be handled by both classes adequately, but sniper's cash support and hitscan capability gives him the edge at range and in solo engagements (not that they should ever really happen in Mann Up mode.)
For primary, it's not too important, but the Hitman's Heatmaker appears to be the best pick, due to it's 'focus' mechanic. Kills will grant you focus, which when at full focus you can activate, granting you 25% quicker charge rate and no-unscoping after firing for a short period. (e.g. Using focus and sniping a giant, you won't have to unscope, meaning you can keep headshotting much faster than you would normally) You can keep the focus period going by getting kills during focus, and explosive headshot* kills also add to the meter.
For secondary I recommend you use the Jarate, and eventually upgrade it to slow, it's drastically more helpful than any SMG or backpack/shield is, (unless you are having a massive issue with spies in something like Wave 666.)
For melee it's somewhat preference as you would probably only be using this against tanks or robo-engi teleporters. I'd recommend anything but the Tribalman's Shiv, as buildings and tanks will not be affected by bleed.
This section will assume you are in a generic MvM Team Comp with the addition of sniper, consisting of: (Scout, Soldier, Heavy, Engineer, Medic, Sniper) Seeing as you are one of the four main damaging members of your team, you play a distinct roll that realistically only Demo and Sniper can play due to their one-shot lethality, which is dealing with uber medics and other annoying need-to-die-fast enemies.
*Explosive Headshots - This upgrade for your Rifle is undeniably the single most important upgrade, as on lower waves you will probably be bombarded with smaller enemies, which means they should be grouped up. When you headshot an enemy in the middle of a group, you will zap all bots near your target for (150 / 170 / 190) damage and slow them (50% / 65% / 80%) for (2 / 3 / 4) seconds, based on the amount of points allocated (This also increases the radius of the effect but I sadly don't have the exact units). This means just one point into this upgrade means you can clear a group of 5 scouts in one headshot as long as they are close.
This damage does not scale down based on how many enemies are hit, so you can deal massive damage with one headshot. I'd recommend putting at least one point into this straight away. (Note: I do not know exactly what this does with the Sydney Sleeper right now, but I imagine it doesn't effect the jarate effect beyond what it is in PvP, but still zaps. If this is even an upgrade anymore for it.)
Damage for Rifle - Obviously you're going to want to deal more damage, and considering you're far away you will probably want to deal more damage rather than buy resistances at this time. This is more preference than anything, as it's all about if you feel confident in sniping with no resistances for the first couple of waves.
Consider Resistances AND support - Upgrade your resistances if you find yourself harrowed by the site of the next wave. Crit Resist is always a safe bet too as you are very squishy.
Your Jarate is a very important tool to help your team crush the oncoming robots with AoE mini-crits, put out your medic, and has a slowing upgrade.
Otherwise if you have spare money and already upgraded your jarate max, you can continue to upgrade your damage/fire-rate/overall ammo (if you are lacking an adequate engineer).
Charge Rate - I feel a few would disagree, but I don't think that charge rate for your primary is too useful, as you should be dishing out higher damage while continuously headshotting than waiting for it to charge up the shot.
Projectile Penetration - With Explosive Headshots, it won't really matter what's behind your target anyway, unless you're hitting two targets that are long distances apart, but that's highly unlikely to be consistently happening.
Health on Kill - You shouldn't be taking too much damage, and if you are, you're probably way too close to the front-line. Taking continuous damage means you're going to be much less accurate scoped-in. Resistances will cover your survivability enough.
Jarate: None. Max the upgrades. (And make sure to try keeping Jarate on cooldown unless you're saving it for Giants.)
SMGs: Most of them, what are you doing using an SMG? Just trial run a jarate or ask a teammate for one. (Even if you are technically asking for their pee???)
Backpack/Shields: There aren't any upgrades, but even if there were, they would probably be useless. Equip the jarate and never look back.
All: Health on Kill is once again useless, unless you're going full rambo-sniper, rushing on in with your Kukri with some hype music in the background. Attack speed will actually increase your DPS against tanks though.
Putting it bluntly, you shouldn't be taking too much damage throughout a match. There are a few places that are safe for you to snipe from and not get into too much trouble, but it depends on where the rest of your team positioned and how easily you can access ammo, be it from dispensers or ammo packs.
On Decoy you will usually find yourself in or on the center 'shack', looking down the main lane. This may become an issue when you get giants and they get too close.
On Coaltown you will probably find yourself planted on or in the main building looking down the first lane. You have good access to ammo, health and a good ramp to chuck jarates down. Just make sure you're aware of how close the bots are as they may sometimes come up the staircases on your left and right and bat your skull in.
On Mannworks there's not a load of great positions to snipe. Potentially the only map you may choose something else due to lack of sightlines that have cover. This may vary depending on the wave's content and wave's route.
On Bigrock Sniper suffers the same issue of sightlines. With no real 'center' to snipe from at any part of the map, you'll need to rely on a solid frontline in the to push up with your team to get the most out of your damage, definitely worth investing in resistances.
On Mannhattan, this is sniper heaven. No pesky tanks, long sightlines and plenty of giants to headshot. Over abundance of uber medics to drop. I recommend buying crit resist when large groups of crits come rolling in on the next wave, as even at range a crit heavy bot can demolish you with 24 dmg per bullet. Generally you can go wherever your sniper instincts tell you to go as there are so many places to sit. Keep an eye on the top right at the frontlines, as snipers will drop in and shoot at your team and risk your medic's life.
On Rottenburg you can definitely still be a useful member of your team, but sightlines are less than perfect. Plenty of tanks, and sir nukesalot will not make your day fun. Take care in your positioning when compared to your team, as you will almost always be on the frontline and don't want to be left behind when your team retreats.
This should have answered all you needed to know and more. Happy Robot Hunting.
(Any statistics included in this answer were provided by the Official TF2 Wiki)