Generate Alias via Templating?

I’d like to generate shortened aliases for URLs using the templating language. the general idea is to use them for QR Codes. I would like to generate these aliases instead of having them predefined like described in the URL Management docs

Maybe a bit of pseudo code illustrates my idea, the following should be considered as part of the front matter in this example:

alias:
  - {{ printf "/%s/%s/" (substr .CurrentSection 0 1) (substr (.Permalink | relURL) 0 1) }}

Otherwise is .Aliases writeable from a template? Or is there a way to call the internal template for generating aliases with custom params?