In a large (12-inch) skillet, warm the butter over medium heat. Add the onions and cook, stirring occasionally, until they are soft and translucent, about 8 to 10 minutes.
Stir in the sugar and kosher salt, then reduce the heat to low. Cook the onions for about 1 hour, stirring occasionally. Patience is key. When they're done, they should be dark, caramelized, and borderline jammy.
Stir in the Madeira, cook for a 2 to 3 more minutes until the liquid is combined, and then add the cooked pasta to the pan. Shower on a generous dusting of Parmesan. Using two large spoons, toss the pasta with the sauce.
Serve with additional grated Parmesan, and flaky salt if desired.
