Even then. A sniper shot likely wouldn't pierce Batman's armor,
It depends on the armor and the rifle. Sniper rifles tend to be much more powerful than handguns, submachine guns or even military assault rifles. I've seen footage of a .50 caliber sniper rifle punching through a Kevlar vest like it was made of Kleenex.
and it's almost impossible to make a sniper shot from miles away.
Actually, it's completely impossible. The range on the best sniper guns is just over a mile
Also (I'll find the scan if necessary) Batman has dodged sniper fire before.
It's possible to do that. The Barrett M-82 fires a round at a muzzle velocity of slightly under 1000 yards / second. If Batman knew exactly when and where the shot was coming from and was far enough away, he could. The problem isn't reflexes, it's spotting the sniper and seeing the muzzle flash. The bullet is supersonic so you won't hear anything until after it hits you.
So, while Batman has dodged sniper fire, that's no guarantee he will be able to dodge it again.
But there's also no guarantee that Castle would be able to lure Batman into a position where could take a shot at him. When someone is that stealthy the sniper has a real challenge.
So no, Castle wouldn't win on his own terms. Batman is to smart, too strong, and too skilled for Punisher. But obviously in this specific scenario, Batman loses to the team.
I'd bet on Batman against Punisher, but it's by no means an automatic win.