I don’t think that part of Mail is scriptable. I don’t recommend using Mail’s blocked message filter because it overrides Mail extensions. This means that SpamSieve won’t be able to protect you from Mail deleting a good message, and also it’s hard to know when to train SpamSieve if Mail is deleting some messages that it incorrectly thought were good.
That script is discussed more here. It’s intended for messages that SpamSieve did classify correctly but where you want to block the sender in the future. You could add that functionality to the remote training script, though I think this is a very niche use case that most people don’t need, and it will cause problems if you don’t properly use it.