I’m not sure you can. If you look at the doco for variables you’ll see you can’t set the keys in the yaml file using variables.
Note: You can only use variables in serverless.yml property values, not property keys. So you can’t use variables to generate dynamic logical IDs in the custom resources section for example.
I think it’s the same for all providers but I’ve linked to the AWS one.
You should be able to change the path though, because that is a value, not a key.
Taking a step back though, why do you want to do this? It seems to break the usual tradition of building a single artifact and promoting it up through your environments. If you change things when it goes to production, you haven’t really tested what is being deployed in your CI environment.
The Serverless framework automatically names your Lambda based on the service, stage and function name. So if your service is called sls and the function is chameleon and you’re deploying to a stage ci then the lambda will be named sls-ci-chameleon. When you deploy to prod it would become sls-prod-chameleon. You don’t need to do anything for this to happen.