UDF - hhhmmm.... with a DV Choice Value

In a badge I am using Theme Color with this code…
How can I put that as a UDF where you have specify the object types???
FunctionName(Parameter1:DataType1, Parameter2:DataType2):OutputDataType = Formula

Any thoughts on this… I realize it’s experimental. But I’m using the same code 4 times in my app, manually done in each of the badge property. That’s a perfect use of a UDF isn’t it?

Switch(
    ThisItem.RYG,
    ChoiceRYG.Red,
    'BadgeCanvas.ThemeColor'.Danger,
    ChoiceRYG.Yellow,
    'BadgeCanvas.ThemeColor'.Warning,
     ChoiceRYG.Complete,
    'BadgeCanvas.ThemeColor'.Success,
     ChoiceRYG.Green,
     'BadgeCanvas.ThemeColor'.Success
     ,
    'BadgeCanvas.ThemeColor'.Informative    
)