I can't speak for Apache configurations, but on-the-fly cert lookup is possible in nginx using the lua_nginx module[1] - IIRC that feature was developed by Cloudflare, to power their SSL termination.
[1]: https://github.com/openresty/lua-nginx-module/#ssl_certifica...