Preheat the oven to 375°F. Lightly grease a 9x13-inch baking dish.
Bring a large pot of salted water to a boil. Cook the ziti for 2 minutes less than the package directions. Drain well and set aside. Do not rinse the pasta.
While the pasta cooks, heat the olive oil in a large skillet or Dutch oven over medium-high heat. Add the ground beef and diced onion. Cook for 6 to 8 minutes, breaking up the beef as it browns, until the beef is cooked through and the onion has softened. Drain excess grease if needed.
Add the garlic, 1/2 teaspoon kosher salt, black pepper, Italian seasoning, crushed fennel seeds, and crushed red pepper flakes. Cook for 30 seconds to 1 minute, stirring often, until fragrant.
Stir in the marinara sauce, crushed tomatoes, tomato paste, and sugar, if using. Reduce the heat to medium-low and simmer for 8 to 10 minutes, stirring occasionally, until the sauce thickens slightly and the flavors come together.
In a medium bowl, stir together the ricotta cheese, egg, 1/4 teaspoon kosher salt, 1/4 cup Parmesan cheese, 1 cup mozzarella cheese, and parsley or basil, if using.
Add the cooked ziti to the meat sauce and stir until the pasta is evenly coated.
Spread half of the sauced pasta into the prepared baking dish. Dollop the ricotta mixture over the pasta and gently spread it into an even layer. Add the remaining sauced pasta on top.
Sprinkle evenly with the remaining 2 cups mozzarella cheese and remaining 1/4 cup Parmesan cheese.
Bake uncovered for 25 to 30 minutes, until the cheese is melted, the edges are bubbling, and the top is lightly golden. If the top browns too quickly, loosely cover the dish with foil.
Let the baked ziti rest for 10 minutes before serving.