Place the sourdough starter, bread flour, warm water, fine sea salt, and 30 milliliters olive oil in a large bowl. Mix until no dry flour remains and a sticky dough forms. Cover and let the dough rest for 15 minutes.
With lightly oiled hands, perform a series of stretch and folds directly in the bowl by lifting one side of the dough and folding it over itself. Rotate the bowl and repeat until all sides have been folded. Cover and rest for 15 minutes, then repeat this process 2 more times for a total of 3 fold sessions.
Cover the dough and let it rise at room temperature for 90 minutes, or until puffed and noticeably expanded.
While the dough rises, heat 15 milliliters olive oil in a large skillet over medium-low heat. Add the sliced onions and granulated sugar. Cook, stirring often, for 25 to 30 minutes until the onions are soft, deeply golden, and caramelized. Remove from the heat and let them cool slightly.
Pour 30 milliliters olive oil into a 23-by-33-centimeter metal baking pan and spread it across the bottom and sides. Transfer the dough to the pan and gently stretch it toward the corners. If it resists, let it rest for 10 minutes and stretch again.
Cover the pan and let the dough proof for 30 minutes until relaxed and slightly puffy. Meanwhile, preheat the oven to 220 degrees Celsius.
Drizzle a little oil from the pan over the top of the dough if needed, then use your fingertips to dimple the surface all over. Scatter the caramelized onions evenly across the top, followed by the shredded Gruyere and black pepper.
Bake for 25 minutes, rotating the pan halfway through, until the focaccia is golden brown, the cheese is melted with browned spots, and the edges are crisp.
Remove the focaccia from the pan or carefully loosen it and let it cool on a rack for 10 minutes. Finish with flaky sea salt if using, then slice into 12 pieces and serve warm or at room temperature.