Is 略字 (handwriting simplification) used only in informal writing (like a diary or post-it annotations) or is it used in more formal situations (like teacher/professor blackboard writing or an essay)?
Well, there are many types of 略字. https://ja.wikipedia.org/wiki/%E7%95%A5%E5%AD%97
Short answer: it might be used on blackboard.
Generally speaking, I don't think primary school teachers use them, and also unlikely secondary school teachers. I remember my history teacher in high school using 口 for 国. But it was rather a memorable exception. As for essays, probably it does not make much sense because everything is typed these days.
Almost the 略字 everybody uses and recognizes would be 冂 (with vertical stroke at the top) for 門（see the link above）. Including this one, there are a number of abbreviations that surprise nobody if used by teachers, but not so many.
Personally I think people (including me) just use characters deformed in their own way, not the clearly defined variant of those characters.