In two cases the accounts receive unwanted emails where the sender has hacked somebody else's account and used the account to target me/ my family with some dubious threats. The apparent "sender" is always different so is difficult to block
Is there a way of re-routing the unwanted emails (by keyword search of the subject) to the spam folder?
This depends on the client you are using. If it can do message filtering using information from a hesder field and you are using IMAP so uploading is possible you can copy spam messages from Inbox to the Spam folder on the server. I do that routinely using Thunderbird.