I have talked with Apple support and read many articles on this issue. According the support, level 1 and 2, there is not way to turn off notifications for filtered unknown senders (iMessage or SMS). I am calling them on this BS. If you can code to filter unknown senders then you can code for muting the notifications for these message. Apple can do it they are either dragging their feet or do not want to do it.
Secondly, we need to push back on our carriers to do something about and not charge the subscriber of their service for it.
I did find out, you can have your carrier block email to text. I have no reason to receive text originating from email. This stopped nearly 75% of my issue. Yours may be different but I feel your pain.