There are many things which Chazal forbade because it appears like arrogance. They said that not everyone is allowed to perform extra-pious acts in public. There are methods of weighing the matter, and it all depends on the situation. If we are discussing something which is clearly prohibited, or transgressing a positive commandment, be it biblical or rabbinic, where most people are not careful to keep this commandment and he would like to make sure to keep it, and he cannot do it only in private, then he should do it publicly and he should not worry that it will be considered arrogant. On the contrary, he should not be embarrassed if people mock him, for it is better for a person to be embarrassed in this world than to be embarrassed in the next.
On the other hand, something which most authorities consider to be permitted, but there are those who are stringent, one should not behave in a stringent manner in public unless he has already acquired for himself a good name and is acknowledged by everyone to be a pious man, and he knows clearly that everyone calls him “The holy one”, and no one has a bad word to say about him. If the above is not true, ha may be stringent as much as he wants but only in the privacy of his own home. In the view of the public, however, he must not differ from the general custom.