Dot the potato and onion slices with butter. If using, sprinkle chopped fresh rosemary over the top. Fold the foil over to create a sealed packet.
Carefully open the foil and sprinkle shredded cheddar cheese on top. Reseal the packet and cook for an additional 3 minutes to let the cheese melt before serving.