I don't think you understand how environments work as seen from the comments. Environment configuration is used to achieve EXACTLY what you are trying to do but this resolving variable thing is not how you do it.
Your SERVER1 is one of your environment and your SERVER2 is your other environment.
So instead of having a convoluted 'DATABASE_URL_%env(resolve:SERVER)% and then resolving $SERVER, the easier (and correct) way to do it as follows.
Instead of defining you SERVER variable, you should define you APP_ENV variable in a .env.local file (this file is local to the server and is not committed). https://symfony.com/doc/5.4/configuration.html#selecting-the-active-environment
So for example, on server1, create a local file called .env.local and set the APP_ENV to "server1".Similary on server2, do the same with APP_ENV value as "server2".
Then you can set the secret url for DATABASE_URL (the same variable for both servers) using the secret command as shown in this documentation. "prod" and "dev" refers to the env so replace prod or dev with server1 or server2 as applicable. https://symfony.com/doc/5.4/configuration/secrets.html#create-or-update-secrets
Now Symfony will automatically resolve and choose the correct value of secret based on the APP_ENV value in the local file. Read about environment configurations to know better how this works.
About you question whether your weird way of doing it is possible, the answer is no. It is not supported in Symfony because that is not the correct way to do it and there is no reason this needs to be a thing.