Is it ethical for a journal editor to use a generic rejection response when desk rejecting a manuscript?
Yes.

It is ethical—and moreover, common and accepted practice—for a journal editor to provide the response that you quote to many authors.

You've received what is commonly known as a desk rejection, where the editor uses their own judgement to determine whether the paper is suitable for and likely to be accepted for publication in the journal.  If the editor's professional judgment is that your paper is out of scope, or that there is no realistic chance of acceptance, then this response is not only ethical but the best response you can hope for, because the near-certain alternative is several months waiting for referee reports followed by rejection.