One separated database for each realm

How do I have each realm’s data stored to a different database, while only hosting a single instance of keycloak? Can I achieve this using custom providers? If so, please give me some pointers.

If you mean by “realm data” just user storage, you can use Keycloak’s User Federation functionality. There is a built-in implementation for LDAP, and you can build your own using the User Storage SPI.