Bring a large pot of well-salted water to a boil. Add the elbow macaroni and cook until just shy of al dente according to the package directions, usually about 1 to 2 minutes less than fully cooked. Drain well and set aside.
While the pasta cooks, heat the olive oil in a large skillet over medium heat. Add the sliced onions and 3 grams of the kosher salt. Cook, stirring often, for 25 to 30 minutes until the onions are deeply golden, soft, and caramelized. Lower the heat if they begin to brown too quickly. Transfer the onions to a bowl.
Preheat the oven to 190 degrees Celsius. Lightly butter or oil a 2-liter baking dish.
In a large saucepan, melt the butter over medium heat. Sprinkle in the flour and whisk constantly for about 1 minute until a smooth paste forms and the raw flour smell fades.
Slowly pour in the warmed milk while whisking continuously to prevent lumps. Cook for 3 to 5 minutes, whisking often, until the sauce thickens enough to coat the back of a spoon.
Whisk in the remaining 3 grams kosher salt, Dijon mustard, garlic powder, and black pepper. Reduce the heat to low, then add the Gruyere and 35 grams of the Parmesan a handful at a time, stirring until fully melted and smooth.
Fold the cooked macaroni and the caramelized onions into the cheese sauce. Stir until the pasta is evenly coated, then transfer the mixture to the prepared baking dish and spread it into an even layer.
In a small bowl, combine the panko breadcrumbs, remaining 15 grams Parmesan, and chopped parsley. Sprinkle the mixture evenly over the mac and cheese.
Bake for 18 to 20 minutes until bubbling around the edges and golden on top. Let the dish rest for 5 minutes before serving so the sauce can settle slightly.