iMessage - How to block SMS from contacts without phone numbers?
SMS delivery is something your cellular carrier has the most control over. They make money delivering SMS so the trick is to convince them to let you not receive “fake” sms with bogus caller ID. That really varies by carrier and region so once you’re sure you’ve configured you SMS service as you want it, then the iOS settings are next best thing to try.

Contact your carrier - https://support.apple.com/en-us/HT204039
Use Apple settings - https://support.apple.com/en-us/HT201229

Filtering all unknown SMS and using do not disturb work best for me, but you may have to experiment with the controls to find your best mix of getting messages you want, not seeing those you don’t need to see immediately and engaging blocks on ones that are annoying pests.
In the end, you can’t block a number that doesn’t get reported correctly from the carrier or that you don’t know. Apple has a service added to allow third party applications to screen your calls - https://support.apple.com/en-us/HT207099  but this doesn’t (yet) work for potentially screening junk messages.