Unique Users databases for each subdomain

I’m writing an app where organisations sign up to create a private instance of the app at a subdomain, eg. company.myapp.com, and then the organisation’s employees individually signup to use the app.

How can I force the default Accounts package to use a unique Users database for each subdomain? I’ve managed to get all the application databases unique for each subdomain.

Alternatively I could use a single Users database but make the subdomain part of the user record, and allow usernames to be resused on different subdomains (I need to allow non-email usernames, e.g “admin”). But how could I do that?

Any help is greatly appreciated!