Preheat oven to 350 degrees F (175 degrees C). Grease a casserole dish.
Bring a large pot of lightly salted water to a boil. Cook elbow macaroni in the boiling water, stirring occasionally until tender yet firm to the bite, about 8 minutes. Add baby spinach to the pot in the last minute of cooking; drain.
Melt 2 tablespoons butter in a saucepan over medium heat; cook and stir onion until translucent, about 3 minutes. Stir garlic into onion mixture and cook until fragrant, about 1 minute. Whisk 2 tablespoons pesto, flour, black pepper, and salt into onion mixture until smooth; whisk milk in gradually. Cook and stir milk mixture until slightly thickened, about 2 minutes; stir in 1 1/2 cups Cheddar cheese, 1/2 cup Parmesan cheese, and 1/2 cup Asiago cheese; remove saucepan from heat and stir until cheeses are melted, about 1 minute.
Stir cheese mixture into macaroni mixture; pour into prepared casserole dish. Cover dish with aluminum foil.
Bake in the preheated oven for 25 minutes. Remove casserole from oven; increase oven temperature to 450 degrees F (230 degrees C).
Melt remaining 1 tablespoon butter in a small saucepan; stir in remaining 2 tablespoons pesto, 1/4 cup Cheddar cheese, 1/4 cup Parmesan cheese, 1/4 cup Asiago cheese, and bread cubes. Remove casserole dish from oven, uncover, and top with bread mixture.
Bake casserole with topping in the preheated oven, uncovered, until bubbly and golden, about 10 minutes.