Melt the butter in a pan over a moderate heat. Add the shallots or onion, season well with salt and pepper and fry for about 5–10 minutes (depending on whether you’re using shallots or onions), until soft and just beginning to brown. Remove from the heat and stir in the thyme. Put to one side to cool.
Lightly flour a work surface and roll out the dough to a rough rectangle about 3mm thick. Sprinkle with the Parmesan, then fold the pastry over itself four times to create four layers of cheese. Wrap the pastry in baking paper and refrigerate for about 10–15 minutes, to rest.
Preheat the oven to 190°C/Fan 170°C/Gas 3.
Lightly flour your work surface and roll out the chilled pastry to a rough circle about 28cm in diameter and about 3mm thick.
Transfer the pastry circle to a baking sheet lined with baking paper and coarsely grind black pepper over the top, giving it a final roll to press the pepper into the dough.
Add the cooked shallot or onion in an even layer, leaving a 4cm border around the edge. Sprinkle the topping with salt and pepper and dot most of the goat’s cheese over the top.
Add the tomato slices and drizzle with olive oil, sprinkle over the sugar and season with salt, then dot over the rest of the goat’s cheese. Fold the edge of the dough over the tomatoes to create a 4cm crust.
Brush the crust edge with the beaten egg and put the tart in the fridge for 15 minutes to rest.
Bake the galette for 40–50 minutes, until the pastry is crisp and golden and the tomatoes are very soft and starting to colour.
Remove from the oven and allow to cool for 5 minutes before serving.