Can I punish myself for a sin without being exposed in society?
الجواب حامدا و مصلیا
It is not permissible for someone to implement punishments (such as Hudood and Tazeer) upon oneself. However, there is no problem in making fasting a few days, Nafl Salah, charity etc. incumbent upon oneself as a form of self-admonition. In fact, this will make it easy for one to stop committing sins.