Grate the zucchini into a colander using the large holes of a box grater. Toss with 1 tablespoon salt, then place in the sink to drain, about 15 minutes. Squeeze out the excess liquid.
Meanwhile, melt 4 tablespoons butter in a large saucepan over medium heat. Add the flour, nutmeg, cayenne, 2 teaspoons salt, and black pepper to taste and mix with a wooden spoon to make a paste. Cook, stirring, until the paste puffs slightly, about 3 minutes. Slowly whisk in the milk, then add the thyme, bay leaves and lemon zest and bring to a boil, stirring. Reduce the heat and simmer until thickened slightly, about 25 minutes. Strain into a bowl; discard the herbs.
Meanwhile, position a rack in the upper third of the oven and preheat to 425 degrees F. Bring a large pot of salted water to a boil; add the pasta and cook until al dente, about 8 minutes. Drain and add to the sauce.
Melt the remaining 4 tablespoons butter in a skillet over medium heat. Add the shallots and cook until translucent, 2 to 3 minutes. Add the zucchini and cook, stirring, until almost tender, about 4 minutes. Add the zucchini mixture to the pasta along with the egg yolks and all but 3 tablespoons of both cheeses; stir to combine, then add the spinach.
Transfer the mixture to a 9-by-13-inch baking dish and sprinkle with the reserved cheeses. Bake until browned on top and heated through, 25 to 30 minutes. Let rest 10 minutes before serving.