That's called stylometry and it can be surprisingly accurate under the right conditions.
https://www.newscientist.com/article/mg21228442-600-miscarri...
Then again a lot of forensic techniques seem to fall into the same category:
https://www.bbc.com/future/article/20150512-can-we-trust-for...
A lot of the problems come from human bias and over-stating the accuracy of tests at trial.