I don't have a kid that age so I don't have parental advice but I got in trouble in school a few times for similar responses.

Changing the tone probably won't happen easily. Changing the wording so that he says the same thing in a way that doesn't get him in trouble might be a easier goal.

I actually enjoyed the extra challenge of irritating teachers I didn't like but doing it in a way for which I couldn't really get in trouble.