I tried to have him sit apart from the men, based on how he felt separated from the enlisted men. Also no, he didn't write it the trenches, just some artistic liberty.
(This is not to nitpick your drawing, just personally curious) - is it known that Tolkien wrote drafts of the Hobbit/LotR during the war? That'd be an interesting tidbit.
Even if it's not 100% accurate, the war certainly stuck with him deeply through the rest of his life and obviously had large influences on his world building and writing.
I believe he either stated or wrote in letters that he imagined with world of the Hobbit during World War 1, but I do not believe he drafted it outright during wartime.
So it depends, mostly, on how we define 'wrote' to be accurate.