How can I set the error indicator (little red triangle) of a node in the editor?

No

Node validation is only done when the configuration dialoge for that node is closed. It is triggered via either the required field on a property or the validator function returning false.

As a rule nodes should not care about other nodes on the canvas.

Based on the series of questions you have been asking both here and on Stack Overflow I suggest you start a new topic here explaining what you are actually trying to do so we can advise if it is going to work.