Q. If a Jew comes late to class (in college, etc.), is it a Chillul Hashem? If he is running late, would it be better not to come at all than to walk in with a yarmulke and tzitzis and a long beard ten minutes late (or however late he is) and make a Chillul Hashem? Every situation is different (it would depend on how often he comes late, how makpid the professor is against lateness, if it is common or uncommon to be late), but if a person knows that it would be a Chillul Hashem in his situation, especially due to his extremely religious appearance and/or other factors, then would it be actually prohibited for him to step foot into the classroom late?
The poskim mention that a talmid chacham who woke up late should not come to the minyan, if his coming will result in a Chillul Hashem, and I personally know a person who missed tefilla b’tzibbur because of this reason (and he is an extremely religious person). What would the Rav’s advise?

A. Indeed Ohr LeTzion (p. 66) and Tiferes Tzion (p. 219) and others quote from Gedolim that when they realized they would be late for tefila, they would daven on time in a different shul to avoid giving rise to chilul Hashem. Our sages teach (Kidushin 69b); one transgresses on chilul Hashem, wittingly or even without intention.
Horav Shlomo Miller Shlit’a pointed out that chilul Hashem could be created even when it affects only the perpetrator himself and no one else is observing. The Talmud (Yuma 86a) mentions; What is chilul Hashem; RabiYochanan explains using himself as an example. If I were to walk four amos without learning Torah or donning Tefilin. However, not wearing Tefilin is evident and manifest and creates in his case a chilul Hashem. Learning Torah is not so obvious, since he could be deeply immersed in Torah thoughts and no one would know; you cannot tell what is in someone else mind. Yet the chilul Hashem would still be created for the person himself. (see Schar Sochir p. 137).
The Mishna in Pirkei Avot (4: 5) also teaches; Whoever desecrates the Name of Heaven in secret will be paid back in public. Whether one acts unintentionally or intentionally, [both are accountable] regarding the desecration of the Name.”
However, the Rov also mentioned that occasionally arriving late to class, if others do so often may not be necessarily a chilul Hashem. The same may apply to coming late to davening if there is a valid reason for it.

Rabbi A. Bartfeld as revised by Horav Shlomo Miller Shlit”a