If the spam is coming from other instances, one option is "limited federation" mode which uses allowlists instead of blocklists. However, this will also greatly restrict which accounts can follow and interact with people on your server. (More info: https://fedi.tips/creating-an-isolated-server/)