Are there rules or guidelines on when and where to use the kanji spelling for this word? From my own observations, it seems like it is spelled 余り when used as a noun meaning remainder or leftovers:
an act of tossing out the remains of drinks
Or as a suffix to a counter meaning more than that amount:
My parent's house is just over 2 hours away from here by train.
In it's other uses it seems to be spelled あまり.
Indeed, in this other post, there are some examples of this. And I also realize that some kanji words are written in kana, but this seems to be a little more rigid than personal preference or maybe I'm reading too much into it.