Is there a way to do math operations on weight groups?
Not directly - but you can easily convert the vertex weights into vertex colors (which are available in the material using the Attribute node) and use maths nodes to combine them.

Start by selecting your Vertex Group in the Mesh properties and create a matching Vertex Color set - it's probably a good idea to give them the same name.



Select the Vertex Weight and corresponding Vertex Color set that you want to copy over. 

Bring up the operator window (Space in Blender versions before 2.8, F3 in 2.8+) and start typing “Vertex Color from Weight” (note that you need to be in Vertex Paint or Weight Paint mode for that operator to be available) and run it to copy the weights to the colors.



You can now access the colors (which contain a copy of the weights) using the Attribute node by simply specifying the name of the color set to use. So, to combine them as A-B and mix based on the result you could use :