Do editors allow authors to respond to reviewers when a paper has been essentailly rejected?
The most likely scenario is that the authors can respond to the editor, and the editor will decide (at their discretion) whether or not to pass back the message to the referees.

After all, there are valid reasons to message the referees afterwards (for example if the main argument for rejection is based on a misunderstanding). For a simple thank you, it will depend on the editor's preference, but it definitely doesn't hurt to try.