Peel the yellow onions and slice them thinly. Place them in a large mixing bowl.
In a separate bowl, combine the flour, baking powder, salt, pepper, and optional sugar.
Add the egg and water or buttermilk to the dry ingredients. Mix until a thick, scoopable batter forms.
Stir the sliced onions into the batter until they are evenly coated.
Pour the oil into a deep skillet or frying pan to a depth of approximately 1–2 inches. Heat over medium heat until it reaches about 350°F (175°C).
Drop spoonfuls of the onion mixture into the hot oil. Flatten each portion slightly with the back of a spoon.
Fry for approximately 2–3 minutes per side, or until the fritters are golden brown and crispy.
Transfer the cooked fritters to a paper towel-lined plate to remove excess oil. Serve warm.