Thundersnow is just a thunderstorm that produces snow instead of rain. For a thunderstorm to exist there needs to be a strong updraft (air rising) in the cloud. An updraft is what feeds a thunderstorm. The updraft sucks up warmer moist air into the clouds. In a normal thunderstorm, water droplets would freeze as they rise. The ice pellets bounce around in the cloud. As the ice pellets collide into each other they cause a positive and a negative charge. The electrical charge builds until it is discharged as lightning.
The same thing has to happen for thundersnow. The thunderstorm needs a strong updraft for the snow and ice to collide inside the cloud. The snow and ice in the cloud also cause a positive and negative charge. The charge builds until it discharges as lightning.
Thundersnow is rare because it is harder for a thunderstorm to grow during the winter because the air is cold, dry, and stable. While, during the summer the air is warm, moist, and unstable. These 3 ingredients help form a thunderstorm.