How can I get domain name like site\.com in nginx template?

I need a domain name with an escaped dot character for some rules in my configuration nginx. The rules are the same for some sites, so I decided to move them to the configuration template. The problem is that it use a domain in format in regular expressions. Is there a simple way to generate a domain in that format in the template? I can use %domain_idn% placeholder. But how i can replace “.” to “.” and “-” to “-”?