Answer
Use a Script Task (not a Service/System Task expression) to build the concatenated string with plain JavaScript string concatenation — for example execution.setVariable('KeyRef', 'CompanyId=' + execution.getVariable('CompanyId') + '^'). There's no need to wrap the concatenated pieces in the ${...} expression-language syntax inside a script task the way you would in some other workflow fields — plain JavaScript string concatenation with + is what actually works there.