Go to Admin > Workflows > Automations > Ticket creation > New rule and set up a rule as shown below:
Conditions:
In Tickets > If Requester email > Contains any of > test.com OR spam.com
Actions:
Mark as spam
You can also reorder the rules added. Here's a video that can help - https://www.youtube.com/watch?v=Gt2VWBeuBU8