Even though Sierra has already given a very nice answer, it is written from the perspective of the author of a post who is receiving frustrating comments and doesn't really address what to do if one is only writing comments or is a bystander. So, here's $0.02 on those scenarios from a moderator.
TL;DR Feel free to comment if you think it will be helpful, but use your judgment. If things are going off the rails, raise a flag or ping a moderator in chat to get our attention, and we can often get things back on track before they get worse. As one of my fellow moderators put it, often the best response is just to flag it and walk away. There are people who are used to dealing with those situations and have the tools to do so.
General Principle: Yes
Yes, it is appropriate to caution someone about their tone, but be careful! How you say it matters. Compare, for example, these:
Don't be such a jerk.
Lighten up, man.
Being a &$#@(@#$ isn't going to help you get an answer.
with something like this:
Welcome to the site! We want to help you, but it's a little hard to understand your question. Please add a Minimal, Complete, and Verifiable example so that we can understand what you need. No one is trying to attack you; we're just not sure yet what you want.
The first three examples are just picking a fight with an already-frustrated user. The fourth one at least has a chance of getting a reasonable response.
This Particular Scenario: No
In this case, being nice wouldn't have counted for a hill of beans. The user was a little snarky at first, posting comments like these (lightly edited, with some added formatting to highlight the relevant bits):
I know it is pointless what I am trying to do. But what I am doing in the example is irrelevant. It really is just an example. The question is simple: [remainder deleted]
Yeah... Obviously I know that...
I understand that but I don't think I have to say what is preventing me from using formatter (specially when it is kinda obvious I would know formatter given I know what is a format string), nor any other alternatives, or I might end up with a gigantic question. I think the original question (even the one without the notes) was already clear and simple enough. You probably should have posted a comment to my question, in the first place, asking why not use formatter, before posting an answer.
what part of "is it possible to access to the xAxis categories in the labels format string" you don't get? Is that question not clear enough???? And by your logic, you think I also should have said on my post that I cannot use another JS charts library as an alternative? Do you understand my point now?? Or should I make a f*****g [sic] drawing?
The first few were not very nice, but they didn't necessarily require any tone correction. Were they nice? No. Was asking the user to change tones likely to help? No.
Only the last comment was really inappropriate. But that one was so far over the line that flagging the comment as rude or offensive was the only meaningful option you had left. If someone receives an answer he or she doesn't like and flips out like this, a "watch your tone" comment is just spitting into the wind.
Why it Wouldn't Have Mattered Here
In fact, after that last comment got deleted but before anyone did anything else, the user posted this gem:
my last comment was censoured, apparently so I will say again: you didnt have to guess anything, you simply had to say yes, it is possible (and how), or no, it isnt (and tell why not). Understand now you stupid fu#$%ng moron? [Edited to mask profanity.]
The user then vandalized the actual question, turning it into a string of profanity, and got into a rollback war with yours truly. (For those without 10k access, the user managed to work 4 insults and 3 obscene words into a 7-word statement, which is pretty impressive.) I suspended the user, who then asked for the account to be deleted. I happily obliged.
The Big Picture
Sure, please try to help keep things civil. We really want everyone to "Be Nice." But realize that some people are not going to be nice, or even reasonable, or even sane. This is why we can't have nice things. So, use your judgment regarding whether a comment is worth the effort or is more likely to lead to someone losing their mind for no apparent reason.
Key takeaway: Don't feed the trolls. If you need someone to step in, raise a flag, ask a meta question, or ping a moderator in chat.