You can also define it as a parameter and then reference it in your template. One advantage to doing it this way is that you don't have to worry about specifying the version number. (I can imagine that there may be circumstances where people would say "¿No version number is an advantage? Bah!".)
Parameters:
SomeParameter:
Type: AWS::SSM::Parameter::Value<String>
Default: '/path/to/my-param'
...
MyFunction:
Type: AWS::Serverless::Function
Properties:
...
Environment:
Variables:
MY_ENVIRONMENT_VAR: !Ref SomeParameter
When you look at the Parameters tab in CloudFormation (in the AWS Console) now you'll only see the string '/path/to/my-param' next to the key SomeParameter; however, when you go look at your Lambda function (in the environment variables section), you'll see that it has resolved to whatever value is stored for the parameter named /path/to/my-param.