Place a rack in top third of oven; turn on broiler. In an 8" cast-iron or ovenproof skillet over medium heat, melt butter.
Add garlic and half of scallions and cook, stirring, until fragrant, about 1 minute; season with salt.
Add corn and sugar and cook, stirring, until corn softens, 1 to 2 minutes.
Remove from heat. Fold in mayonnaise and 3 ounces cheese until cheese is melted.
Sprinkle with remaining 3 ounces cheese.
Broil corn mixture, watching closely, until golden brown and bubbly, 4 to 6 minutes.
Top with remaining scallions.