If I don't know the kanji of a thing but I know the hiragana of it, can I just write the hiragana if I have to write it down? Is it a free choice? Or some rules or social formalities?
First, as @TheWanderingCoder states, sometimes hiragana can be ambiguous.
かみ can be
髪(Hair) for example. So Kanji is required here to understand the intended meaning, even though there are situations where it is understood from context.
To answer your questions
Can I just write the hiragana if I have to write it down?
Most of the time, yes as people will understand from context. I've seen people write
会ギ on whiteboards before because
議 is a pain to write.
Be careful though, a big glob of Hiragana/Katakana is hard to read. Japanese speakers (readers?) "chunk" the text by Kanji, so too much Kana will take them longer to read.
Is it a free choice? Or some rules or social formalities?
1) There are modern preferences that exist, for example
おいしい is often written in Hiragana and not as
美味しい. You can experiment with your preferred style as the choice can give a different persona, particularly when chatting/texting. Heavy use of Hiragana can come off as young and sometimes feminine.
2) Take this phrase that you will write at the bottom of every business email you write in Japanese
Quickly looking through my emails, the following patterns all occur:
The top being the least formal and the bottom being the most. Note though, the difference in formality is not that big. If I get an email with the 1st pattern vs the 3rd, it's not an insult or anything like that.
I'm pretty sure I've seen
宜しく御願い致します before too, which would be even more formal.
I personally use
よろしくお願い致します, but on formal/serious emails I will use
If you write a thing in hiragana that should be written in kanji, it looks like a kid who didn't know kanji so much wrote it. There's no rigid rule whether you use kanji or hiragana, but you should use kanji in something formal. And it's better to use kanji even in informal texts.
but there are some exceptions. If the kanji of the things is difficult to write even for Japanese, we usually write them in hiragana or katakana. ex) rose is 薔薇(bara) in kanji, but it's hard even for Japanese to remember the kanji, so we usually write ばら.
mirka's final comment in
How can one stop “去年教職” from looking like a weird 4 kanji compound?
Kanji/hira/katakana is a pretty deliberate choice, especially in writing intended for publication (speaking from my experience in the industry). Sometimes it's to stop a secondary kanji from “sticking out” (食べ始める→食べはじめる), sometimes it's to alter the nuance of a word (かれ/彼/カレ, よみがえる→蘇る). They all change the “feel” to the reader, and it's one of the things that make Japanese such an expressive language.