Mix flour, sugar, yeast, and salt in the bowl of a stand mixer fitted with the dough hook on low speed to combine, about 1 minute. With the mixer running, pour in the water and the egg, mixing well after each addition. Continue mixing, scraping down the sides of the bowl as needed, until the dough is cohesive but still a bit sticky, about 3 minutes. Add the margarine and mix to fully incorporate it into the dough. Increase the speed to medium and mix until the dough is smooth and elastic, 7-9 minutes. Cover the dough with plastic wrap or a clean kitchen towel. Set the dough in a warm place and let rise until doubled in size, about 1 hour.