How to set default value for Legend format if variable not available

Name Description
Legend format Controls the name of the time series, using name or pattern. For example {{hostname}} will be replaced with label value for the label hostname.

Legend format can let us use variable such as {{foo}} and display its value bar for example,
Is it possible to set a default value when variable {{foo}} is not available?
for example, instead of display foo (as variable foo is missing), just set it to empty or other default value?