I am unaware of a direct way to do this. You could accomplish this indirectly by testing the WSDL from the connected instance against a list of known WSDL documents corresponding to different versions. I know of at least 4 different WSDL documents corresponding with the following versions. There may be more possibilities than the ones I list.
LM 2.5
LM 3.0.0
LM 3.0.1 and LM 3.0.2 (both ship same WSDL)
LM 4.0.0
In the change between 3.0.0 -> 3.0.1 they changed the portType as shown below binding. Our automation is in Java that is generated from WSDL. The minor change between 3.0.0 and 3.0.1 was enough for us to have to keep two sets of LM specific binaries to communicate to the two different LM versions we currently have deployed..