Does packer support user-defined functions?

I see that there a several built-in functions available in HCL2, but is there a way to create one for use within the build block?

As an example, my template has a couple PowerShell provisioners separated by a windows-restart provisioner. Each of the PowerShell provisioners runs a script that is stored on an Azure file share that is mapped using New-PSDrive.

Mapping the drive is the first thing done inside the build block, but it has to be done again after the restart. Rather than duplicate the relevant code, I’d like to be able to define it in one place and refer to it in each provisioner block.

Does packer support this as a user-defined function or other built-in feature?