Can Conditional Variable Assignment be Done in Azure Pipelines?

I was closer than I thought. This is not pretty, but it worked. (with more yaml context)

variables:
  ${{ if eq( variables['Build.SourceBranchName'], 'master' ) }}: 
    buildVersion: ${{ variables['mavenVersion'] }}
  ${{ if ne( variables['Build.SourceBranchName'], 'master' ) }}: 
    buildVersion: ${{ variables['Build.SourceBranchName'] }}

  buildKey: ${{ format('{0}_{1}', variables['supportReleaseNumber'], variables['buildVersion']) }}
  buildNum: $[counter(variables['buildKey'], 1)]  # same as $(Rev:r), but more widely usable 

name: $(buildKey)_$(buildNum)  # build run name

As an extension to @Mike Murray's answer, if you are using variable groups you must define additional variables as name value pairs. To use conditional variable assignment in this case would be as follows:

variables:
- group: 'my-variable-group'
- name: myfirstadditionalvariable
  value: 100
- name: myconditionalvariable
  ${{ if eq( variables['Build.SourceBranchName'], 'master' ) }}: 
    value: masterBranchValue
  ${{ if ne( variables['Build.SourceBranchName'], 'master' ) }}: 
    value: featureBranchValue