I needed a TLS wildcard certificate but it's always a pain to handle, I just found way better!
Caddy web server can generate TLS certificates on demand, so I can make it listen on *.foobar.com and when a new subdomain is requested, it will generate a new ACME certificate for this.
https://caddyserver.com/docs/automatic-https#on-demand-tls
It has limitations though, it can be easy to DOS the system by requesting a lot of subdomains. That's why it's possible to add a mechanism "ask" as a safe-guard. The implementation is up to you, but a simple solution could be a persistent timer that would only allow a new certificate every minute.
See the following link for the "ask" option https://caddy.community/t/serving-tens-of-thousands-of-domains-over-https-with-caddy/11179