Preheat the oven to 350°F (175°C). Line a baking sheet with parchment paper and set aside.
In a small saucepan, combine the grated piloncillo and water. Heat over medium heat until the piloncillo completely dissolves.
Remove the saucepan from the heat and stir in the molasses and unsalted butter. Mix until the butter melts completely. Let the mixture cool for 10 minutes.
In a large mixing bowl, whisk together the flour, baking soda, cinnamon, ginger, and salt.
Add the egg and vanilla extract to the cooled piloncillo mixture and whisk until combined.
Slowly pour the wet ingredients into the bowl of dry ingredients while mixing.
Mix until a soft dough forms. If the dough feels sticky, refrigerate it for 20 to 30 minutes.
Lightly flour a clean surface and roll the dough to approximately ¼-inch thickness.
Cut the dough into pig shapes using a pig cookie cutter or template.
Transfer the cookies to the prepared baking sheet, leaving about 1 inch of space between each cookie.
Bake for 10 to 12 minutes or until the edges are set while the centers remain soft.
Allow the marranitos to cool on the baking sheet for 5 minutes before transferring them to a cooling rack.
Serve warm or at room temperature with coffee, Mexican hot chocolate, or café de olla.