Put oven rack in middle position and preheat oven to 350°F.
Cut off and peel neck of squash, then cut neck crosswise into 1/2-inch-thick rounds (reserve round portion for another use). Season both sides of slices with salt and pepper. Heat 2 tablespoons oil in a 12-inch nonstick skillet over moderate heat until hot but not smoking, then cook squash, in batches if necessary, until browned, 3 to 4 minutes per side. Add water to skillet and cook squash, covered, over moderately low heat until tender, about 5 minutes. Gently transfer squash with a spatula to a 2-quart gratin or other shallow baking dish, overlapping slices if necessary, then pour any juices from pan over squash.
Cook onions and garlic in remaining 2 tablespoons oil in skillet over moderate heat, stirring frequently, until soft, about 8 minutes. Stir in tomatoes with juice, oregano, allspice, and salt and pepper to taste and simmer 3 minutes.
Cover squash with tomato mixture and crumble feta on top, then sprinkle with nuts.
Bake gratin until heated through and cheese is softened, about 10 minutes.