No it isn't.
Firstly, the whole point of compat mode is that it is pretending to be whatever old version of IE has been specified. The UA string is changed by default as part of that, and it is identical to the UA string provided by a real copy of the old IE version that is being emulated.
Secondly the browser mode (ie rendering mode) and the document mode (ie the user agent) can be set separately in the dev tools; it is possible to be in IE8 compat mode but still show the IE10 user agent.
In short, trying to detect compat mode using the UA string is a bad idea; it's simply not possible, and even if it were possible, it could easily be spoofed.
However, you should never have a valid reason to actually need to do this. If your site is telling IE to display the page to compat mode, then the server should already know this; it shouldn't need to check. There are a few edge cases where it might come up unexpectedly, but you can work around those with the X-UA-Compatible
meta tag.
Best practice is to avoid compat mode if at all possible anyway; if you've written your site properly, compat mode should be completely unnecessary. If you do find yourself needing it, you'd be better off fixing your code to work properly in IE10.