Blend together the flour and salt in the bowl of a mixer or food processor fitted with a steel blade. Work the flour and salt until blended, and with the machine on, add the butter on piece at a time. Add the sour cream or yogurt, and blend until the dough forms a ball, less than a minute.
Roll out the dough onto a lightly floured work surface into an 11 to 12 inch wide circle about 1/ 8 inch thick. Fit into a 9 inch tart or pie pan, trimming the overhand to 1/2 inch over the sides. Fold the edges under and crimp the edge of the dough. Refrigerate while making the filling.
Clean the leeks by slicing lengthwise and run under cool water to remove any grit. Pat dry, and slice the white portion into ½ inch sections, including about an inch of the green. The very top green is not as tender, reserve for soup stock.
Melt the oil in a large skillet over medium high heat. Add the leeks and cook, stirring with a wooden spoon to prevent from burning, often until soft, about 15 minutes. Stir in the sugar, salt and pepper.
Reduce the heat to low and cook, stirring often, until the leeks are golden brown and have a sticky texture, about 25 minutes. Remove from the heat, stir in the Marsala wine, thyme, and rosemary. Gently cook for another 5 minutes, turn off the heat.
Position a rack in the center of the oven and preheat to 375*. Prepare the filling: In a medium bowl, beat together the egg with the ricotta. Transfer the mixture evenly into the pastry shell, spread evenly and distribute the caramelized leeks.
Bake until the pastry is golden brown, 35 minutes to 40 minutes. Remove from the oven, sprinkle with fresh minced garlic and rosemary and let stand for 10 minutes to cool slightly before serving.