I suspect that, a bit like email addresses, being very selective about who you give your "address" to is the most important bit.
Sadly, phone numbers, unlike email addresses, are such a small address space that it's possible to just message all of them.
The only other service/medium where I get comparable (really any) spam is SMS/email.
I've never, and I mean never, have received a spam message over iMessage.
https://eur-lex.europa.eu/legal-content/EN/TXT/?uri=CELEX%3A...
My anecdote is that iMessage is only place where I get spam almost daily. All other messengers - once per month, at most.
I remember that it made sense and seemed plausible to me at the time because I've also actually never received a spam iMessage in my whole life. It never even occurred to me in that moment this was the case until I read that comment and was like, "O yeah, right, I've actually never gotten spam on iMessage come to think of it." I just assumed that to spend spam via iMessage required apple hardware or that for one reason or another it just wasn't very viable.
On the other hand, I have gotten a lot of sms spam in the past, and I continue to get spam on WhatsApp.
As a side note, my sms spam has decreased dramatically after I ported my mobile number to google voice vs. when my carrier was T-Mobile. It's anecdotal but still telling.
I hope you're reporting the spam you get to Apple, because the fastest way to stop it is to have the offending account terminated.