Preheat oven to 400°. Line a rimmed baking sheet with parchment paper.
Heat oil in a large deep-frying pan over medium heat. Add onion, a pinch each of salt and pepper, and cook, stirring occasionally, until onion is translucent, about 3 minutes. Add spinach and nutmeg and cook, stirring occasionally, until spinach is wilted, about 5 minutes. Pour cooked spinach into a fine-mesh strainer and drain well, pressing to release as much liquid as possible.
Coarsely chop spinach mixture. Scrape into a medium bowl and stir in ricotta and parmesan. Set aside to cool to room temperature.
In a small bowl, whisk together egg yolk, 1 tsp. water, and 2 or 3 drops food coloring. The egg wash should be deep orange; add more coloring if needed. Set aside.
Unroll pie pastry from package onto a lightly floured work surface. With a 4- by 5-in. pumpkin-shaped cookie cutter, cut 8 pumpkins from pastry. Spoon 1/4 cup spinach mixture into middles of 4 pumpkins and spread to 1/4 in. from edge. Brush exposed dough lightly with water. Top filled pumpkins with remaining 4 pumpkin cutouts and crimp edges with a fork to seal.
Set pumpkin hand pies on prepared baking sheet and brush with colored egg wash. Cut a jack-o'-lantern face into each. Bake pies until brown and crusty, 20 to 25 minutes. Cool on a rack, then chill in an airtight container. Bring to room temperature to serve.
*We used India Tree Nature's Colors, available at well-stocked grocery stores and on amazon.com.
Make ahead: Up to 2 days, chilled airtight.