01 - Preheat your oven to 400°F (200°C). Lightly grease a 9x13 inch (23x33 cm) baking dish.
02 - Boil the pasta in a large pot of salted water until it reaches al dente. Drain thoroughly and set aside.
03 - While the pasta cooks, heat the olive oil in a saucepan over medium heat. Add the finely chopped onion and sauté for 3 to 4 minutes until softened. Incorporate the minced garlic, dried oregano, and dried basil; cook for an additional minute until fragrant.
04 - Stir in the tomato passata, tomato paste, sugar, salt, and pepper. Allow the sauce to simmer uncovered for 10 minutes, stirring periodically.
05 - In a large bowl, combine the drained pasta with the tomato sauce. Add half of the shredded mozzarella and grated Parmesan cheeses. Mix gently until evenly coated. Transfer this mixture to the prepared baking dish.
06 - Distribute the remaining mozzarella and Parmesan cheeses evenly over the surface of the pasta mixture.
07 - Arrange the pepperoni slices in a single layer atop the cheese.
08 - Bake uncovered for 20 to 25 minutes, or until the cheese is melted and bubbly, and the pepperoni edges are crisp and browned.
09 - Allow the casserole to rest for 5 minutes before serving. Garnish with fresh basil, if using.