Earlier quoted context omitted.
I was just spitballing, but it's possible: First you coat or anodize the magnesium, which I imagine needs to be done in any case. Then you apply a layer of epoxy. Then you wrap in carbon/epoxy. Done properly, there's no direct contact between carbon and magnesium, and you're probably less likely to see corrosion in the Mg-CF composite than you are with magnesium by itself.
The epoxy barrier might work, but in general encapsulated metals are risky because they are impossible to inspect for corrosion and cracking so fail without warning, and the encapsulation can block surface oxide formation which causes crevice corrosion- especially if small amounts of salt and water get in there, which they will over time, even in epoxy. I’m sure what you are saying could be done- especially to basica…
I reckon it'd be a lot easier to just increase the wall thickness if you want that section of a carbon frame to be stiffer