Activate yeast by combining warm milk, sugar, and yeast in a large bowl. Let sit for 10 minutes until frothy and bubbly. If nothing happens, your yeast is dead—start over with fresh yeast.
Make dough by adding melted butter and salt to yeast mixture, then gradually mixing in flour until soft dough forms. Knead for 5-6 minutes until smooth and elastic. Cover and let rise for 1 hour until doubled.
Caramelize onions while dough rises by heating oil and butter in a large skillet over medium heat. Add sliced onions and cook slowly for 25-30 minutes, stirring occasionally, until golden brown and sweet.
Season filling by stirring thyme, salt, and optional sugar into caramelized onions. Let cool completely before using. Hot filling melts cheese prematurely and makes dough soggy.
Roll dough on a floured surface into a large rectangle about 12x18 inches. The thickness should be about ¼ inch throughout. Use a rolling pin for even thickness.
Add filling by spreading cooled caramelized onions evenly over dough, leaving a ½-inch border. Sprinkle Gruyere cheese and black pepper over onions. Don't overstuff or it leaks during baking.
Roll into log by tightly rolling dough from the long side into a cylinder. Pinch seam to seal. The tighter you roll, the better the spiral pattern shows after cutting.
Cut and twist by slicing the log lengthwise down the center, leaving one end intact. Twist the two halves around each other with cut sides facing up, then form into a circle and pinch ends together.
Second rise on a parchment-lined baking sheet covered loosely with a towel for 20 minutes. The dough should look slightly puffy. Preheat oven to 375°F during this time.
Bake at 375°F for 25-30 minutes after brushing with melted butter and sprinkling with rosemary and flaky salt. The wreath should be deep golden brown. Brush with more butter immediately after baking for glossy finish.