Preheat the oven to 350°F (175°C). Spray a 9-inch pie dish with cooking spray and set aside.
Cook the spaghetti in a large pot of boiling salted water according to package directions until al dente; drain well in a colander.
Return the drained pasta to the pot or a large bowl and toss with the butter until melted and evenly coated.
Stir in the egg and the grated Parmesan until combined and the egg is fully incorporated into the pasta.
Press the pasta mixture firmly into the bottom and up the sides of the prepared pie dish to form a pasta crust.
In a bowl, mix the ricotta cheese with the Italian seasoning until evenly combined, then spread it over the pasta crust in an even layer.
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 of the sauce.
Bake the pie in the preheated oven for 20–25 minutes, or until the cheese is golden and bubbly.
Remove from the oven and let rest briefly, then slice into 8 pieces and serve topped with chopped fresh basil if desired.