Prep the oven and pan: Heat oven to 400°F (200°C). Lightly grease a 9x13-inch baking dish or similar casserole.
Prepare the “ziti” base: For zucchini, slice lengthwise into 1/4-inch planks, then cut into strips about 2–3 inches long.
For spaghetti squash, roast halves cut-side down at 400°F until tender (about 35–45 minutes), then scrape into strands. Toss zucchini or squash with olive oil, salt, and pepper.
Roast the noodles: Spread the prepared zucchini or squash on a sheet pan. Roast 12–15 minutes for zucchini (until just tender), or 10 minutes for spaghetti squash to steam off excess moisture.
Pat dry with paper towels to reduce wateriness.
Brown the meat: In a large skillet over medium-high heat, cook ground beef or sausage, breaking it up as it browns. Drain excess fat if needed.
Add aromatics and sauce: Stir in onion and cook until soft, 3–4 minutes. Add garlic for 30 seconds.
Pour in marinara, Italian seasoning, and red pepper flakes. Simmer 5–7 minutes. Season with salt and pepper.
Mix the ricotta layer: In a bowl, combine ricotta, egg, and Parmesan.
Stir until smooth. Add a pinch of salt and pepper.
Assemble the bake: Spoon a thin layer of meat sauce into the baking dish. Add half the roasted “ziti.” Dollop and spread half the ricotta mixture.
Sprinkle one-third of the mozzarella. Repeat layers: sauce, “ziti,” ricotta. Finish with remaining sauce and the rest of the mozzarella.
Bake: Reduce oven to 375°F (190°C).
Cover loosely with foil and bake 20 minutes. Remove foil and bake 10–12 minutes more, until bubbling and golden in spots.
Rest and serve: Let the casserole rest 10–15 minutes to set. Sprinkle with chopped parsley or basil if using.
Slice into squares and serve warm.