Yes you can do this. But mind, that it will only work for http
sites, not https
.
You need to change your blocking mode to IP.
https://docs.pi-hole.net/ftldns/blockingmode/
And modify the blocking page, which is located at var/www/html/pihole/
You might find more info using the forum's search function, e.g.