To perform localized Gaussian filtering either 2D or 3D in MATLAB, you would need to provide the filtering function with that specific portion of image that needs to be filtered. This could be done by using matrix indexing to extract the regions that need to be filtered.
Note: As filtering images requires spatial contiguity, filtering would make sense if the 3D binary mask has voxels that are in each others neighborhoods. In other words filtering individual voxels would not yield any useful result.
Thus, taking an example where filtering is being performed on a 100x100x3 region in an image, it could look like:
originalRGB = imread('peppers.png');
imshow(originalRGB)
sigma = 2;
% perform gaussian filtering on entire image
volSmooth = imgaussfilt3(originalRGB, sigma);
figure
imshow(volSmooth)
% local filtering on a certain region in an image.
volSmooth2 = imgaussfilt3(originalRGB(100:200,100:200,:), sigma);
finalVol = originalRGB;
finalVol(100:200,100:200,:) = volSmooth2;
figure
imshow(finalVol)
This was an easy illustration to show how indexing can be made use of for rectangular regions. Moreover, I do not believe sparse spatial filtering is possible in MATLAB as of now (wherein you could just give a sparse matrix and have the filter operate on that).
Hence, a suggestion would be to get the regions of interest in bounding boxes and pass those boxes as inputs to the filtering function.