Cook elbow macaroni in boiling salted water until al dente, about 8 minutes. Drain and set aside.
8 oz elbow macaroni
Return pot to medium heat and melt 2 tablespoons unsalted butter. Whisk in 2 tablespoons flour and cook, whisking constantly, for 1 minute.
4 tbsp unsalted butter, 4 tbsp all-purpose flour
Slowly pour in warmed milk while whisking, then continue cooking until sauce thickens and bubbles, about 4 minutes.
2 cups whole milk
Remove from heat and whisk in dry mustard, salt, black pepper, and cayenne pepper until smooth.
1 tsp dry mustard, 0.5 tsp salt, 0.25 tsp black pepper, 0.125 tsp cayenne pepper
Stir in shredded sharp cheddar cheese until fully melted, then fold in cooked macaroni until evenly coated.
2 cups shredded sharp cheddar cheese, 8 oz elbow macaroni
Transfer mixture to an 8×8-inch baking dish, dot with remaining butter, and bake at 350°F for 20 minutes, until sauce is bubbling around the edges and top is lightly golden.
Cover the pan and chill in the refrigerator for at least 2 hours, or until firm.