It doesn't seem to have a fixed formal definition, but perhaps reading Maimonides' description of it will help you get the right picture. At the end of the fifth chapter of Yesodei haTorah (which discusses mostly the laws of "dying al kiddush hashem"), he writes (5:10-11):
כל העובר מדעתו בלא אונס על אחת מכל מצוות האמורות בתורה, בשאט בנפש להכעיס--הרי זה מחלל את השם; ולפיכך נאמר בשבועת שקר, "וחיללת את שם אלוהיך, אני ה'" (ויקרא יט,יב). ואם עבר בעשרה מישראל, הרי זה חילל את השם ברבים. וכן כל הפורש מעבירה או עשה מצוה, לא מפני דבר בעולם, לא פחד ולא יראה, ולא לבקש כבוד, אלא מפני הבורא ברוך הוא, כמניעת יוסף הצדיק עצמו מאשת רבו--הרי זה מקדש את השם.
ויש דברים אחרים שהם בכלל חילול השם, והוא שיעשה אדם גדול בתורה ומפורסם בחסידות, דברים שהברייות מרננים אחריו בשבילן, ואף על פי שאינם עבירות--הרי זה מחלל את השם: כגון שלוקח ואינו נותן דמי הלקח לאלתר, והוא שיש לו, ונמצאו המוכרין תובעין אותו, והוא מקיפן; או שירבה בשחוק, או באכילה ושתייה אצל עמי הארץ וביניהן; או שאין דיבורו בנחת עם הברייות, ואינו מקבילן בסבר פנים יפות, אלא בעל קטטה וכעס; וכיוצא בדברים האלו. הכול לפי גודלו של חכם--צריך שידקדק על עצמו, ויעשה לפנים משורת הדין.
וכן אם דיקדק החכם על עצמו, והיה דיבורו בנחת עם הברייות, ודעתו מעורבת עימהם, ומקבילן בסבר פנים יפות, ונעלב מהן ואינו עולבן, מכבד להן ואפילו למקילין לו, ונושא ונותן באמונה, ולא ירבה באריחות עמי הארץ וישיבתן, ולא ייראה תמיד אלא עוסק בתורה עטוף בציצית מוכתר בתפילין, ועושה בכל מעשיו לפנים משורת הדין--והוא שלא יתרחק הרבה, ולא ישתומם הרבה--עד שיימצאו הכול מקלסין אותו ואוהבין אותו, ומתאווין למעשיו: הרי זה קידש את השם, ועליו הכתוב אומר "ויאמר לי, עבדי אתה--ישראל, אשר בך אתפאר" (ישעיהו מט,ג).
English from Chabad.org:
Halacha 10
Whoever consciously transgresses one of the mitzvot related in the Torah, without being forced to, in a spirit of derision, to arouse [Divine] anger, desecrates [God's] name. Therefore, [Leviticus 19:12] states, regarding [taking] an oath in vain: "[for] you are desecrating the name of your Lord; I am God." If he transgresses amidst ten Jews, he desecrates [God's] name in public.
Conversely, anyone who refrains from committing a sin or performs a mitzvah for no ulterior motive, neither out of fear or dread, nor to seek honor, but for the sake of the Creator, blessed be He - as Joseph held himself back from his master's wife - sanctifies God's name.
Halacha 11
There are other deeds which are also included in [the category of] the desecration of [God's] name, if performed by a person of great Torah stature who is renowned for his piety - i.e., deeds which, although they are not transgressions, [will cause] people to speak disparagingly of him. This also constitutes the desecration of [God's] name.
For example, a person who purchases [merchandise] and does not pay for it immediately, although he possesses the money, and thus, the sellers demand payment and he pushes them off; a person who jests immoderately; or who eats and drinks near or among the common people; or whose conduct with other people is not gentle and he does not receive them with a favorable countenance, but rather contests with them and vents his anger; and the like. Everything depends on the stature of the sage. [The extent to which] he must be careful with himself and go beyond the measure of the law [depends on the level of his Torah stature.]
[The converse is] also [true]. When a sage is stringent with himself, speaks pleasantly with others, his social conduct is [attractive] to others, he receives them pleasantly, he is humbled by them and does not humble them in return, he honors them - even though they disrespect him - he does business faithfully, and does not frequently accept the hospitality of the common people or sit with them, and at all times is seen only studying Torah, wrapped in tzitzit, crowned with tefillin, and carrying out all his deeds beyond the measure of the law - provided he does not separate too far [from normal living] and thus become forlorn – to the extent that all praise him, love him, and find his deeds attractive - such a person sanctifies [God's] name. The verse [Isaiah 49:3]: "And He said to me: `Israel, you are My servant, in whom I will be glorified'" refers to him.