Melt the butter in a large skillet over medium-low heat. Add the onions, season with 1⁄2 teaspoon salt and 1⁄4 teaspoon pepper, and cook, covered, stirring occasionally until softened, 8 to 10 minutes.

Increase heat to medium, add the sugar and cook, stirring frequently, until deep golden brown, 15 to 20 minutes (add a tablespoon water if the onions stick or pan browns). Stir in the thyme and cook for 1 minute; stir in the sherry, if using.

Meanwhile, heat oven to 425 degrees F. In a large bowl, mix the cream cheese, sour cream, zest, and hot sauce until smooth. Fold in the Gruye`re, scallions, and onions.

Transfer the mixture to a shallow 3-cup baking dish, place on a rimmed baking sheet, and bake until light golden brown and bubbling, 15 to 18 minutes. Sprinkle with scallions, if desired, and serve with the chips and vegetables.