It depends what you mean when you say you want an RGB image. Consider the following image:
You can make a single-channel gray image into a multichannel gray image:
inpict = imread('cameraman.tif');
gray3pict = repmat(inpict,[1 1 3]);
The same can also be done using MIMT gray2rgb(), with the benefit of also handling images with alpha content.
[ipict,~,alpha] = imread('cameramanwithalpha.png');
iapict = joinalpha(ipict,alpha);
rgbapict = gray2rgb(iapict);
You can also do simple colorization by filling/zeroing channels in a similar fashion:
zeropict = zeros(size(inpict),class(inpict));
redpict = cat(3,inpict,zeropict,zeropict);
magentapict = cat(3,inpict,zeropict,inpict);
onespict = ones(size(inpict),class(inpict));
redbluepict = cat(3,inpict,zeropict,onespict*100);
aquapict = cat(3,0.2*inpict,0.7*inpict,inpict);
Adjusting the hue is another simple way to do the same thing.
adjustedpict = imtweak(redpict,'hsl',[-0.08,1,1]);
There are other ways to colorize that may do a better job of retaining contrast. MIMT has a very basic HSL colorization tool.
gcolorized = gcolorize(repmat(inpict,[1 1 3]),[-80 100 0]);
Very similar things can be done using simple image blending techniques.
cpict = colorpict([imsize(inpict,2) 3],[150 50 255],'uint8');
blendcolorized = imblend(inpict,cpict,1,'lightness');
If you want the color to vary over the image, you can create a colored overlay (or underlay) and combine them using image blending techniques as well.
gradpict = lingrad([256 256 3],[0 1; 1 0],[0 0 1; 1 0 0]*255,'cosine','uint8');
blendpict = imblend(gradpict,inpict,1,'overlay');
You could also simply treat the grayscale values as indices into any arbitrary colormap.
colormapped1 = ind2rgb(inpict,parula(256));
colormapped2 = ind2rgb(inpict,hot(256));
However, that only works so simply if your image is an integer-valued image whose values correspond to the indices of your selected colormap. If your image values are normalized or on some arbitrary scale, or if your colormap length doesn't correspond to the number of gray levels in your image, you'll need to address that before using ind2rgb().
arbitrarypict = rescale(inpict,-29,537);
colormapped3 = mat2gray(arbitrarypict);
colormapped3 = gray2ind(colormapped3,maplength);
colormapped3 = ind2rgb(colormapped3,myCT);
Of course, if you have MIMT, you can do the same thing in one line using gray2pcolor()
colormapped4 = gray2pcolor(arbitrarypict,myCT);
... and it can even mimic the quantization used by imagesc()/pcolor(), which is something you can't get using gray2ind(). colormapped4 = gray2pcolor(arbitrarypict,myCT,'cdscale');
it can even emulate imagesc() right down to the requantization involved in on-screen rendering: colormapped4 = gray2pcolor(arbitrarypict,myCT,'cdscale_display');
There are several built-in colormaps, and there are many more on the File Exchange.
The functions joinalpha(), gray2rgb(), gray2pcolor(), imtweak(), lingrad(), colorpict(), gcolorize(), imsize() and imblend() are part of the MIMT: