Heat oven to 375 degrees. Melt the butter in a medium skillet over medium heat. Stir in the sugar, cayenne pepper, and ½ teaspoon kosher salt. Add the pecans and toss. Transfer to a baking sheet and bake, stirring occasionally, until toasted, about 12 minutes. Add the rosemary and toss to combine. Transfer to a bowl and serve warm or at room temperature.