Preheat your oven to 375°F (190°C).
Cook the penne pasta according to package instructions until al dente. Drain and set aside.
In a large skillet, heat the olive oil over medium heat. Add the sliced onions and cook, stirring occasionally, until they are caramelized and golden brown, about 15-20 minutes.
Stir in the minced garlic, dried thyme, and sugar, cooking for an additional 2 minutes until fragrant.
Pour in the beef broth and heavy cream, stirring to combine. Let the mixture simmer for about 5 minutes, allowing it to thicken slightly. Season with salt and pepper to taste.
In a large mixing bowl, combine the cooked penne pasta with the onion mixture. Stir in half of the Gruyère and mozzarella cheeses.
Transfer the pasta mixture to a greased 9x13 inch baking dish. Top with the remaining Gruyère and mozzarella cheeses.
Bake in the preheated oven for 20-25 minutes, or until the cheese is bubbly and golden brown.
Remove from the oven and let it cool for a few minutes. Garnish with chopped fresh parsley before serving.