Preheat oven to 350°F. Lightly butter a 9×13-inch pan and set aside.
Melt 3 tablespoons butter over medium-high heat in large skillet. Add onions and cook without stirring 7-10 minutes, or until beginning to brown. Reduce heat to medium and stir, continuing to cook, for additional 5-10 minutes or until caramelized. Stir in rosemary. Remove onions from pan and set aside.
Bring large pot of water to boil and cook macaroni noodles until al dente, according to package directions. Drain and set aside.
Meanwhile, melt remaining 3 tablespoons butter in medium saucepan. When butter is melted, stir in flour and stir constantly 3-4 minutes. Add milk and cream slowly, whisking until combined. Bring milk mixture to boil; simmer until thickened, about 5-10 minutes. Add salt.
In small bowl, temper egg with 1/2 cup of hot milk mixture. Pour egg mixture into milk mixture and whisk to combine. Stir in onions, cooked macaroni, and all but 1 cup of shredded cheese. Stir until smooth.
Pour into prepared pan. Top with remaining 1 cup of cheese. Bake 35 minutes, or until lightly browned and bubbly.