Mr. Kumasasa, it does not work with either pumpkins or Jack-o'-lanterns. I have used both with the same negative results.
Here are the screenshots...
I just tried it again, I am using a flat world and I tried it on stone, dirt, and on top of a building. Blocks set down, but Golem does not spawn. This is a local game on just this computer.
Since the introduction of 1.8 I can no longer spawn an Iron Golem. The process worked fine before the update, I would place the Iron blocks, and add a pumpkin on top and the golem would spawn.
Mr. Kumasasa, My apologies, it works now with pumpkins, it did not last night... Not sure why...