There are channel agnostic, native FreePBX subroutines for this. Use a dialplan hook to call like this:
[macro-dialout-trunk-predial-hook]
exten => s,1,NoOp(Entering user defined context [macro-dialout-trunk-predial-hook] in extensions_custom.conf)
exten => s,n,GoSub(func-set-sipheader,s,1(X-Tenant,somename.to.match))
exten => s,n,MacroExit()