Preheat the oven to 375°F and position the oven rack in the upper third. Bring a large pot of salted water to a boil and cook the ziti for 2–3 minutes less than the package directions recommend. Drain well and set aside.
While the pasta cooks, place the Italian sausage and chopped onion in a large pot. Cook over medium heat for 7–10 minutes, stirring occasionally, until the sausage is browned and the onion has softened.
Add the minced garlic, Italian seasoning, and crushed red pepper flakes. Cook for about 1 minute, stirring constantly until fragrant.
Stir in the crushed tomatoes, heavy cream, salt, black pepper, and sugar. Allow the sauce to warm through for about 5 minutes.
Add the drained pasta to the sauce and toss until evenly coated.
Transfer half of the pasta mixture into a 9×13-inch casserole dish, spreading it into an even layer.
Spoon dollops of ricotta cheese over the pasta to create the middle layer. There's no need to spread it perfectly.
Top with the remaining pasta mixture, gently spreading it into an even layer without stirring it into the ricotta.
Sprinkle the Parmesan cheese evenly over the top, followed by the mozzarella.
Bake uncovered for 20 minutes, or until the casserole is hot and bubbling. Finish by broiling for a few minutes, watching carefully, until the cheese develops a lightly browned top.
Garnish with chopped fresh basil and/or parsley before serving, if desired.