Add the butter to an ovenproof skillet over medium heat until melted. Pour in 2 tbsp water. Sprinkle the sugar evenly over the surface and don't mix. Cook over medium heat, until the sugar dissolves and bubbles.
Once the sugar is golden brown, season with a pinch of salt and pepper. Nestle the onion wedges into the caramel in a circular pattern. Cook for 15-20 minutes on medium-low, spooning caramel over the tops so they start to soften and glaze. Sprinkle with herbs. Remove the pan from the heat and gently push the onions as close as possible together with a spoon, towards the center of the pan, maintaining the pattern.
Remove the pie dough from the package and let sit for 10 minutes. Drape it over the onions and tuck the excess dough under itself and around the edges of the onions. Prick pastry a few times with a fork.
Transfer to an oven and bake at 400°F for 25–30 minutes, or until pastry is golden and puffed.
Let it rest 5 minutes. Place a plate over the skillet, then invert in one swift motion. Garnish with flaky salt and extra herbs or cheese if desired.
