Here's a very manual way to tackle this. First I'll generate an array and mask for this purpose. Doesn't really matter what I choose, but good for reproducibility.
arr = ImageData@
RegionImage[
KnotData["Trefoil", "Region"],
3.2*{{-1, 1}, {-1, 1}, {-1, 1}},
RasterSize -> 128
];
mask = ImageData@
RegionImage[
Ball[{0, 0, 0}, 1.5],
3.2*{{-1, 1}, {-1, 1}, {-1, 1}},
RasterSize -> 128
];
Next I use the trick here to get the actual color functions that you're interested in
rainbowOpacityColorFunc =
(Blend[{{0., RGBColor[0.471412, 0.108766, 0.527016, 0.]}, {0.333333,
RGBColor[0.324106, 0.60897, 0.708341, 0.333333]}, {0.666667,
RGBColor[0.764712, 0.728302, 0.273608, 0.666667]}, {1.,
RGBColor[0.857359, 0.131106, 0.132128, 1.]}}, #1] & );
grayLevelOpacityColorFunc =
(Blend[{{0., RGBColor[0., 0., 0., 0.]}, {1.,
RGBColor[1., 1., 1., 1.]}}, #1] & );
finally I use those to convert the masked image and its complement to the appropriate 4-channel versions
alphaData =
(1 - mask)*Developer`ToPackedArray@Map[
Apply[List]@*rainbowOpacityColorFunc,
(1 - mask)*arr,
{3}
];
betaData =
mask*Developer`ToPackedArray@Map[
Apply[List]@*grayLevelOpacityColorFunc,
mask*arr,
{3}
];
and finally I compose the images
alphaImage = Image3D[alphaData, ColorSpace -> "RGB"]
betaImage = Image3D[betaData, ColorSpace -> "RGB"]
alphaImage + betaImage


