Preheat oven to 375°F; grease a 9x13-inch dish.
Cook macaroni according to package until al dente; drain and set aside.
Melt 4 tablespoons butter in a large pot over medium; whisk in flour and cook 1 minute until golden.
Gradually whisk in milk; cook about 5 minutes until thickened, stirring constantly.
Remove from heat; stir in cheddar and Gruyère until melted and smooth.
Add garlic powder, salt, and pepper; fold in macaroni and ham.
Spread evenly in dish.
Mix panko with melted butter; sprinkle over top.
Bake 25-30 minutes until bubbly and golden brown on top; rest 5 minutes before serving.