the minecraft wiki says this about iron golem spawning: "Since Java Edition 1.14, an iron golem spawns based on villager gossip at a gathering point. The villager who starts the gossip must have a profession that is not nitwit, slept in the last 24000 ticks, been to their job site block in the last 36000 ticks, gossiped 5 times about the need for an iron golem, and have four other villagers within 80 blocks. The Iron Golem then has a chance to spawn in a 16×6×16 area centered on the location of the villager who spread the gossip." unfortunately, this says nothing about where the iron golem can or can't spawn. I'm trying to make an iron farm, and a trading system, and I would rather not remove the blocks, but make them spawn proof instead.
Glass has worked for my farm so far I've changed it about 10 minutes ago after my golems were spawning on my half slabs changed it to glass and everything has spawned in the place I need it to including cats
On the Minecraft Wiki, it says:
Mobs will not naturally spawn on transparent blocks, in water (except for squid, drowned, fish, dolphin and guardians), in lava, or on half blocks (slabs, stairs).
So I guess this applies to Iron Golems as well.
To check, you can create a superflat world, find a village, make sure it meets the conditions, and see if one spawns.