You can do this using ffmpeg:
ffmpeg -y -i layer2.gif -i layer1.png -filter_complex [0]overlay=x=0:y=0[out] -map [out] -map 0:a? mergedLayers.gif
-y flag says to overwrite output files without asking. So if you already have a file named mergedLayers.gif it will get overwritten when this command is run.
-i flag is the input url (in this case just a file name). So you are passing two input files. layer2.gif and layer1.png.
-filter_complex flag in a sense is the function that is done on the inputs to make the output. In this case the function is [0]overlay=x=0:y=0[out]. The [0] indicates that you want to use the first input file as the object that is being overlayed on. If you were to use [1] instead of [0] you would end up with the png as the bottom layer. overlay=x=0:y=0 tells where to place the overlayed object. You can adjust where the png appears on the image by changing the x and y values in [0]overlay=x=0:y=0[out]. x=0:y=0 is the top left of the image. Increasing the value for x will move the image to the right. Increasing the value for y will move the image down. If =x=0:y=0 is omitted, overlay defaults to x=0:y=0.
-map flag is a way to designate an input as a source for the output. Probably unnecessary in such a simple case and you could just do:
ffmpeg -y -i layer2.gif -i layer1.png -filter_complex [0]overlay=x=0:y=0 mergedLayers.gif