Global variable for dynamic configuration

Is there any way I can use global or equivalent variables in the service/route/plugin ? For example, backend hostname on dev env is dev-mysite.com and for QA and prod it is qa-mysite.com and prod-mysite.com
So when configuring service I will simply create global variable outside of service/route/plugin and add it in the host section of service. so my hostname will be dynamically populated.
This is useful when we promote our code from lower environment to higher.