There's mod_macro <https://httpd.apache.org/docs/2.4/mod/mod_macro.html> that might be useful. I don't think it does calculations, though, so you might need to do some things yourself. Maybe you could indeed generate the conf files yourself and use Include <https://httpd.apache.org/docs/2.4/mod/core.html#include> or IncludeOptional <https://httpd.apache.org/docs/2.4/mod/core.html#includeoptional>.
I'd like to note that generating port numbers based on domains might work, at first, but if you delete a domain from the list, the numbers will shift. So, a=>16010, b=>16020, c=>16030, etc, becomes a=>16010, c=>16020, for example. For doing the actual reverse proxying, you should probably read this <https://httpd.apache.org/docs/2.4/howto/reverse_proxy.html> and/or this <http://www.apachetutor.org/admin/reverseproxies>. >