Place a large skillet over medium heat and coat with the oil. When the oil gets hazy, add the onions and cook, stirring often, until soft and lightly colored. Set aside.
Place a steamer basket in a large pot and add water to a depth of 1 to 2 inches. Be sure the water does not touch the bottom of the basket. Cover the pot and bring to a boil over medium-high heat. Put the potatoes in the steamer basket. Cover and steam until there is no resistance when a fork is inserted into the potatoes, about 20 minutes.
While the potatoes are hot, put them in a bowl and mash well by hand. (Mashing potatoes by hand may be a little more work, but the potatoes will be light and fluffy if you put in the extra effort.) Make sure there are no chunks of potato left. Mix in the dill and cooked onions; season with salt and pepper to taste. Set aside at room temperature to cool completely. The potato filling may be made up to 1 day ahead and kept in a covered container in the refrigerator.
Make the dough and assemble the piroshki
In a small bowl, combine the yeast, sugar, and 1/4 cup of the warm water; stir gently to dissolve. Sprinkle in 1 teaspoon of flour and let the mixture stand until the yeast comes alive and starts to foam, about 5 to 10 minutes.
Put the remaining flour in a large bowl and make a well in the center. Pour in the remaining 1 cup warm water. Add the margarine and break it up with your fingers into the warm water so it melts. Add the egg, salt, and yeast mixture. Mix with your hands, incorporating more and more flour into the center to form a soft, sticky dough. Lightly dust your hands with flour as the dough sticks to your fingers. Take care not to add too much extra flour, however, or the dough will become dense. Turn the dough out onto a lightly floured work surface and fold it over itself, kneading with the heel of your hand, until it's smooth and elastic, about 5 minutes.
Cut the dough into 6 equal pieces and roll into balls; they should be about 4 ounces each (about the size of a cue ball). Sprinkle the rounds lightly with flour. Cover and let rest for at least 30 minutes so they will be easier to stretch.
Pat each dough piece into an oblong about 6 inches long and 2 inches wide. Mound about 3/4 cup of the potato filling evenly down the length of each piece, keeping a small border all the way around. Dust your fingers with flour and bring the long edges up to enclose the filling, pinching them together to form a tight seal. Check for any holes or tears, making sure the piroshki are completely closed.
Gently pat the piroshki into 8-inch-long pies; they should spread out fairly easily. Turn the piroshki seam side down and gently pat the tops to spread them out. Lightly dust with flour, cover, and let rise again for about 10 minutes while heating the oil.
Pour oil into a cast-iron skillet or deep, heavy-bottomed pot to a depth of about 3 inches and heat to 375°F (190°C) over medium heat. Working in batches to avoid crowding the pot, use a wide flat spatula to carefully lower the piroshki into the hot oil. Fry the piroshki on the first side until golden brown, about 2 minutes, then gently turn and fry the other side for 1 minute longer. Transfer to a platter lined with paper towels and let drain. Use more paper towels to blot any excess oil off the tops. Serve warm or at room temperature.
If you prefer to bake the potato piroshki instead of frying, arrange them on a lightly oiled baking pan and bake in a 375°F (190°C) oven until golden brown, about 20 to 30 minutes.