It’s interesting that you should ask this exact question, and you are also “lucky” as the two publicly shared existing “poof of concept” code samples for automating interaction with the DH Control Panel demostrate how part, or all of this (if you can settle for setting up email forwarding instead of real “mailboxes”), can be done with PHP.
For a code sample that demostrates a way to add a subdomain. check this previous Forum post.
That post also links back to a preceding post that provides code for setting up an email forwarding address.
Of course, neither of these pieces of code are “production ready”, but they do work and show what is involved. This might help start you on the right track for programming a solution.
Make sure you note the caveats about no formal API having been published (and the possibility that a subsequent panel change could break any code you produce).
My only other suggestion is that you should carefully consider if you want to do this. While you likely have enough disks pace and bandwidth in your quotas to make this sound attractive, under the DreamHost “Terms of Service” you will be held responsible for the actions of any users operating under your account.
For a quick overview of how this can get you into trouble, you might want to visit and review The DreamHost Abuse Center.
Good luck, and Welcome to DreamHost!