Start by cooking the pasta according to package directions in a large pot of salted boiling water. Drain and set aside.
While the pasta is cooking, heat the butter and olive oil in a large skillet over medium heat.
Add the sliced onions and sprinkle with salt. Cook, stirring occasionally, for about 15-20 minutes until the onions are soft and caramelized.
Add the sugar to the onions and continue to cook for another 5 minutes, allowing the onions to deepen in color and sweetness.
Pour in the broth, stirring to combine. Bring the mixture to a simmer and let it cook for about 5-10 minutes, allowing the flavors to meld. Season with salt and black pepper to taste.
In the skillet with the onion mixture, add the cooked pasta and toss until it is well coated.
Preheat your oven broiler. Transfer the pasta and onion mixture to an oven-safe dish. Sprinkle the Gruyère and mozzarella cheese evenly on top.
Place the dish under the broiler for 2-3 minutes or until the cheese is bubbly and golden brown.
Remove from the oven and let cool slightly. Garnish with fresh thyme if desired, and serve warm.