Cook the pasta according to package instructions in a large pot of salted boiling water until al dente. Reserve 1/2 cup of pasta water, then drain the pasta and set aside.
In a large skillet, heat 2 tablespoons of olive oil over medium heat. Add the sliced onions and 1/2 teaspoon of salt. Cook, stirring occasionally, for about 15-20 minutes until the onions are golden brown and caramelized.
Sprinkle the sugar over the onions and stir well. Continue to cook for an additional 5 minutes, allowing the sugar to enhance the caramelization.
Add the minced garlic and red pepper flakes to the skillet. Cook for 1-2 minutes until fragrant, stirring frequently to prevent burning.
Add the cooked pasta to the skillet, along with the reserved pasta water and the remaining tablespoon of olive oil. Toss everything together until well combined. Adjust seasoning with salt if needed.
Serve hot, topped with grated Parmesan cheese and fresh parsley for garnish.