Virtualmin WP Workbench plugin can do this, along with other security-related features like enabling additional HTTP password protection for the WP Admin panel.
fail2ban does the blocking.
wp-fail2ban just writes events to syslog. fail2ban (using wp-fail2ban included fail2ban wordpress filters) catches those and blocks offenders.
one would need to add extra parameters to wp-config.php for wp-fail2ban to block eg. user enumerations and disable some annoying health check features of fail2ban, but in general works fine. (no need for premium security plugins if configured correctly)
btw, csf/lfd can do most of what wp-fail2ban+fail2ban does (or other CMS related plugins working with fail2ban), by just using some custom filters in csf. (so no need for extra plugins/daemons).
modsec too, just more complex in terms of writing new rules.
I was considering that I could get a php script to perform a specific event when a bad actor came along an then this would cause them to get blocked, like redirecting them to a bad URL.
firewall blocks ips/ranges/ASNs, doesn’t redirect. a web server/script can redirect.
a php script redirecting to some url, is probably better than triggering/messing with the firewall.