How to include smarty script with mosaico email
As a workaround for the specific example in your post, you can create a custom token.  This post explains how using hook_civicrm_tokens and hook_civicrm_tokenValues