First of all, nowadays it is obvious that colds (and many other sicknesses) are transferred by shaking one's hand with someone who is sick and then kissing the hand. This fact is almost universally known (especially in places like Israel and the U.S.).
It is far from clear that the rabbi would be embarrassed, considering that it was obvious to the congregants that he was sick (since he was coughing through the Shabbat tefillot). It is also common that people wish to avoid getting sick by shaking hands with someone who is sick. It is the rabbi's responsibility to avoid behaviors that can cause others to become sick as a result.
Further, perhaps you should explain that you are not shaking his hand because you don't want to risk catching a cold and then wish him to feel better (Shabbat hee miliz'ok), and/or make a kissing motion towards your hand but don't actually make contact.
Remember, hakol biydei shamayim chutz mitzinim upachim (Kes. 30a). See Tosafos there who point out that people catch colds/flu out of negligence. Further, if you catch a cold you could potentially expose other people, causing them damage (and you should probably avoid shaking other hands subsequently for the same reason).
The Tosafot and Shevut Ya'akov say that public humiliation is not literally tantamount to murder and the implication from that would be that the gemara in Sotah 10b, according to these opinions, should not be taken literally Kol Torah - Rabbi Jachter.
Obviously, nevertheless, if it is possible, a person should avoid embarrassing someone, all the more so in public, a person should avoid it. However, it should be done in a way that avoids causing others harm.
Especially now with the cold (and the flu) going around. If one, due to carelessness, causes others to get sick, it would cause those other people tza'ar and to lose valuable time due to their sickness. If the sickness that is spread is more harmful to one's health (e.g., causing an elderly or weak person to catch the flu, pneumonia, etc.), it can put other people's lives at risk, possibly all because of the carelessness of one individual - a clear instance of pikuach nefesh. People have an obligation to avoid being negligent and causing damage to other people.
To reiterate, a person should try to be sensitive to other people's feelings when they take necessary measures to avoid spreading disease (as described in the third paragraph).
I would recommend speaking to the rabbi in private afterwards and explain to him that it is important that he avoid behaviors (including as you noted in your question) that can cause others to become sick (as it is a type of harm) and that he, as the rav, inform congregants that they should act in kind.