That depends on the images you're using, which graphics software package you use, and what your skill level is... there's a few different way to do it. Usually, the person will prepare one graphic layer that is transparent (with the hat part visible) over the original image. When it's all done, then merge the two layers (images) into one when you save the file.
If you have an image you want this done to... just post it in the thread. There are lots of talented graphics folks here who could do that for you.