Bring a large pot of salted water to a rolling boil. Cook the pasta until it's just shy of al dente, following the package directions. Drain well, then toss with a light drizzle of olive oil to keep the noodles from sticking together.
While the pasta is cooking, heat the olive oil in a large skillet over medium-high heat. Add the chopped onion and cook for 3–4 minutes, stirring occasionally, until softened and translucent.
Add the Italian sausage to the skillet, breaking it into small crumbles as it cooks. Continue cooking until the sausage is nicely browned and reaches an internal temperature of 165°F. Drain off any excess grease, then set the sausage aside to cool slightly.
In a large mixing bowl, combine the ricotta cheese, egg, 2 cups of shredded mozzarella, Parmesan cheese, chopped fresh basil, Italian seasoning, salt, black pepper, red pepper flakes, and minced garlic. Stir until everything is evenly blended. Fold in the cooked pasta and browned sausage, mixing until well coated.
Lightly coat a 9×13-inch baking dish with cooking spray. Spread about 2 cups of marinara sauce evenly across the bottom of the dish. Spoon the pasta mixture over the sauce and spread it into an even layer.
Pour the remaining 2 cups of marinara sauce over the pasta, then sprinkle the remaining shredded mozzarella evenly on top. Cover the dish with aluminum foil and bake in a preheated 375°F oven for 20 minutes. Remove the foil and continue baking for another 10 minutes, or until the cheese is fully melted and the sauce is hot and bubbly.
For a beautifully golden, bubbly cheese topping, broil the casserole on high for 2–3 minutes if desired. Let it rest for about 10 minutes before serving, then garnish with additional freshly chopped basil for a fresh finishing touch.