A few questions.
- What do you do with XXX C0006Z - what should it change to?
- Will the variable always be in the same format? Will it always be the last letter you need to change?
Below is one way to do it.
See full flow below. I'll go into each of the actions. Note that they are all Compose action - I've just renamed them.

The expression I used in the Output is:
concat(
substring(outputs('Input'), 0, sub(length(outputs('Input')), 1)),
substring(outputs('AZ'), add(indexOf(outputs('AZ'), last(outputs('Input'))), 1), 1)
)
Note that in AZ I added A at the end so if the code ends with Z it will be set as A. Not sure what you would want to do in your scenario.