Speaking from a purely mathematical/EV point of view, if there are an even number of players going into day (thus an odd number at the start of the night), shoot the cop, if there are an odd number of players going into day (i.e. evens at the start of the night), shooting the vig is better if close to endgame; shooting the cop is more viable the more players are still alive (although if you know that you can kill the cop tomorrow, you should still shoot the vig). (Note: I'm assuming NAR here: if shooting the vig prevents them from taking their shot, which is nonstandard but something that does happen in some games, the odd/even argument swaps the other way round, and makes shooting the vig a little more helpful in every case.)
This is because a cop confirms (as clear/scum) one player per night, whereas a vig confirms two players every two nights (because after the vig kills two players who would have been ynched anyway, that's effectively skipped two night phases; this gives you a spare mislynch which confirms the player you lynched and also confirms the player the scum nightkill). The cop's confirmations are more useful than the vig's confirmations because they're all aimed by town (as opposed to only half being aimed by town), so in the long term the cop averages as more helpful to the town. On the other hand, shooting a vig while the town's on odds will cause the vig shot to put town into evens, which doesn't help them at all, whereas leaving the vig alive another day would let the vig put town back to odds and give them another two confirmations. So while town's on odds, shooting the vig lets you strand them at an unfavourable player count, giving a short-term advantage. This is more useful than stopping a Cop shot close to the end of the game (and is more useful than stopping a Cop shot if you know you can get rid of the Cop tomorrow). Earlier in the game, it's probably worth taking advantage of an opportunity to get rid of a Cop if you aren't sure you'll get another one, because Cops will give the town a very large advantage over time.
In a real game (as opposed to the mathematical idealization), there are a few other factors to deal with. For example, do you know that the Cop is a full Cop? They're rather more likely to be limited-shot than a Vig is (and likely to have a lower limit when they are limited), and shooting a Cop that's out of shots hardly helps you. Another thing to deal with is that vigs rarely follow the optimal strategy (barring Jesters and the like, the correct shot for a Vig is to shoot whoever they believe is most likely to be lynched tomorrow); if a vig is acting as a loose cannon rather than playing as part of their team, and if their reads aren't great, leaving them alive may be helpful (because if a Vig shoots a townie who wasn't otherwise going to be mislynched, it only helps scum). You also have to take the players' reads into account (if a town power role is likely to investigate and/or shoot you in the near future, you probably need to kill them before they kill you).
scum · scam · seam · team · term · tern · torn · town