Easily done with MacroDroid. I just created a macro to try the concept, and it worked.
Trigger: Connected to wifi network (Any Network)
Actions: Dark Theme (Enable)
I set it to trigger upon connection to any network. It can optionally be configured to trigger only on connection to specific SSIDs. It works with just a single trigger and action, but if you want, you can limit it with Constraints. For example, you could set the macro to only trigger between certain times. Or, say you wanted the macro to run when connected to any network but one... you'd set the trigger for any wifi network (as above), but then add a constraint to not trigger if you connected to that specific network.