Conditional SetEnv in .htaccess?
You can, with mod_rewrite:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^stage\.domain\.com$
RewriteRule (.*) $1 [E=PYRO_ENV:stage]
RewriteCond %{HTTP_HOST} ^www\.domain\.com$
RewriteRule (.*) $1 [E=PYRO_ENV:production]
For conditional settings there is SetEnvIf:
SetEnvIf Host ^stage\.example\.com$ PYRO_ENV=stage
SetEnvIf Host ^(www\.)?example\.com$ PYRO_ENV=production