1) Prepare the dough: In a large bowl, whisk together flour, sugar, 1½ teaspoons kosher salt and 1½ teaspoons black pepper. Add butter and 1 cup grated Gruyère to the flour mixture and toss to coat. Using your fingertips, pinch the butter and cheese into the flour to make pebble-size pieces. Drizzle in the ice water and stir to make a shaggy dough. Dump the dough onto a large sheet of plastic wrap and knead a few times to combine. Wrap in plastic and refrigerate for at least 4 hours.
2) Prepare the onions: In a large skillet, cook the bacon over low head when rendered set bacon aside. Add onions and thyme sprigs, season with 1 teaspoon salt and ½ teaspoon pepper and cook, stirring occasionally, until the onions are translucent and lightly golden on the edges, 20 to 25 minutes. Reduce the heat to medium, add broth and sherry and cook until the onions are browned and the liquid has mostly evaporated but the mixture is still saucy, 16 to 18 minutes. Transfer to a bowl and set aside to cool for at least 30 minutes.
3) Heat the oven to 375 degrees. Roll the dough into a 13-inch round on a sheet of parchment. Spread the cooled caramelized onions on the dough, leaving a 1- to 2-inch border. Fold the edges in, over the onions, sprinkle on the chile flakes transfer to a baking sheet and bake until the dough is golden brown and some of the onions have browned on the edges, 40 to 50 minutes, rotating the galette halfway into the baking process.
4) Remove galette from the oven and sprinkle remaining ⅓ cup grated Gruyère on the crust and the bacon. Bake another 5 minutes to melt the cheese. Remove and let rest for 10 minutes before slicing. Top with remaining thyme leaves, for garnish.