Specify default values for env variables that get populated from ConfigMap/Secret/etc

At the moment, I have defined a few environment variables whose values should be set from specific keys in the config map. However, I want to add default values to these environment variables in case the key isn’t present in config map. What is the recommended method for specifying default values for environment variables in container spec? At the moment, I am doing the following

  - name: MY_VAR
    value: default
  - name: MY_VAR
        name: myconfig
        key: my_var
        optional: true

Cluster information:

Kubernetes version: 1.14.8
Cloud being used: Azure
Installation method: Azure Kubernetes Service
Host OS: Ubuntu 16.04