Bring a large pot of salted water to a boil. Add the pasta and cook just until al dente, about 8 minutes. Drain the pasta and set aside.
In a large pot, melt the butter over medium heat. Reduce the heat to low and whisk in the flour to create a paste. Add the milk and whisk until smooth. Increase the heat to medium and continue whisking until the sauce starts to thicken, about 2 minutes. Stir in the shredded cheese and continue stirring until the cheese is melted and the sauce is smooth. Fold in the pesto.
Add the pasta, stirring to combine, and cook just until the pasta is warmed through. Season with salt and pepper to taste. Serve immediately.