I can only think of formal occasions when I have heard "thank you" spoken this way. Is this the case? Could it perhaps also be spoken sarcastically to have the opposite effect?
Yes, a sarcastic use of this phrase is certainly possible (isn't it the case with almost any phrases?), but it won't have the opposite effect.
One sarcastic use of this phrase that I can think of is:
In other words, when anger works as a motivation. It's probably more common in comics and games than in the real life, but there you go.