In addition to what other posters have said, chemotrophic bacteria can play a significant role concentrating/enriching certain metallic ores by eating dissolved minerals in deep groundwater and metabolizing out metals. Lots of vein-gold runs through very old & fractured marble/granite bedrock with a lot of hydrologic activity.
Easiest things is to wash/disinfect the surface before you carve, like give the pumpkin a nice bleachwater bath. Use clean tools & seal the cut edges with petrolium jelly or WD-40.
Long-term you probably could dry it as a gourd to preserve it, but it’ll shrivel up a lot and look like shit.
Formaldehyde/pickling would also probably work, but i imagine it’d get all mushy.