Preheat the oven to 350°F (175°C). Lightly grease a 9x13-inch baking dish.
In a large skillet, melt butter over medium heat. Add onion and sauté until soft, about 3 minutes. Stir in garlic and cook for 30 seconds.
Sprinkle flour over the onion mixture and stir for 1 minute to eliminate raw flour taste.
Gradually whisk in milk until smooth. Stir in sour cream, 3 cups shredded cheese, red pepper flakes, salt, and pepper. Cook until the cheese melts and sauce thickens.
In a large bowl, mix cooked pasta, chicken, and cheese sauce until evenly coated.
Spread mixture into the prepared baking dish. Top with remaining cheese.
Cook uncovered for 20–25 minutes, until bubbly and golden.
Let rest for 5 minutes before serving for easier scooping.