Melt 1 tablespoon butter in a skillet over medium heat. Add onions and salt and cook for 5 minutes, then lower the heat to medium-low.
Cook onions for 25 to 30 minutes, stirring often, until deep golden and soft. Add only a little of the measured water if needed to lift sticking bits without steaming the onions.
Stir in thyme and sherry and cook for 2 to 3 minutes until no free liquid remains. Transfer onions to a bowl and let steam escape for 3 minutes.
Divide half the Gruyere over 2 bread slices, spread onions evenly over them and add remaining cheese. Close with the other bread slices and spread remaining butter over the outside faces.
Cook in a clean large skillet over medium-low heat for 4 to 5 minutes per side until the rye is crisp and cheese is melted. Rest for 1 minute, cut in half and serve.