Arion is a Nix wrapper tool for docker-compose. Nix is handy for use as a template language. It is actually closer to a general-purpose language than to a template engine, so I guess what you want can be implemented manually, since it only requires config file generation.
Arion docs: https://docs.hercules-ci.com/arion/
Nix language: https://nixos.wiki/wiki/Nix_Expression_Language