Print key value as a class along with the label for a list field?
You should not actually want to do this in your node.tpl file. Drupal uses a system of (pre)processors to alter variables before they get rendered. That is where the logic should go.

Have a look at this topic that has a lot of explanation and references https://stackoverflow.com/questions/2383865/how-do-i-use-theme-preprocessor-functions-for-my-own-templates

Once you have your output ready you should be able to do the styling with CSS.