In most cases you write "an essay on something" but recently I came across some "essays in something"
Is there a difference in meaning? Is the "in" more formal?
The preferred way to introduce the scope, subject or topic of the essay is "an essay on something". Sometimes in is used but it's quite uncommon and "an essay in ..." has several other uses. For example:
publication "In a recent essay in the journal Nature..."
subject "...a most influential essay in speculative thought"
style "students who wrote their essay in cursive..."
year of publication "In your Harper's essay in 1996, you promised that..."