Preheat the oven to 356°F (180°C). In a small bowl, dissolve the sugar and yeast in warm milk, stir well, and set aside for 5 minutes. In a large mixing bowl, combine the flour, salt, egg, and the milk mixture, then mix well with a spatula.
Using a stand mixer with the paddle attachment, knead the dough on medium-high speed for 5 minutes until smooth. Add the butter and continue kneading at the same speed for 15 minutes, or until the dough is elastic. Cover the dough with a cloth or plastic wrap and let it rise in a warm place for 1 hour, or until it has doubled in size.
After the first proof, transfer the dough to a floured surface. Gently press it to release the air. Divide the dough into three equal pieces and cover with plastic wrap. Let it rest for 15 minutes.
Flatten and shape each piece of dough into an oval using a rolling pin. Place two slices of ham and cheese horizontally on the dough. Then, roll it up and pinch the seams to seal.
Cut the dough evenly in half using a dough cutter or knife, then transfer the pieces to the loaf pan with the cut side facing up. Cover and let it rise until doubled in size, about 1 hour.
After proofing, spread mayonnaise over the top of the dough and sprinkle with cheddar cheese and onion slices. Bake for 40 minutes, or until the edges are golden brown. Serve warm or at room temperature.