Preheat the oven to 350°F (175°C). Spray a 9-inch pie dish with cooking spray and set aside.
Cook the spaghetti according to package directions until al dente, then drain thoroughly in a colander.
Return hot pasta to the pot, add the butter and toss until melted and evenly coated.
Stir in the egg and 1/4 cup grated Parmesan until combined; press the pasta mixture firmly into the bottom and up the sides of the prepared pie dish to form a crust.
In a bowl, combine the ricotta cheese and Italian seasoning, then spread the ricotta mixture evenly over the pasta crust.
In a medium skillet over medium-high heat, cook the ground beef, breaking it up, until no longer pink; drain any excess fat.
Add the marinara sauce to the cooked beef, stir to combine, and spread the meat sauce evenly over the ricotta layer.
Sprinkle the shredded mozzarella evenly over the top and bake for 20–25 minutes, until the cheese is melted and bubbly and the top is lightly golden.
Remove from the oven and let rest a few minutes, then slice and serve with chopped fresh basil if desired.