As you might imagine, it is possible to consider this as a purely mathematical problem and to thereby come up with measures of gerrymandered-ness. It is a widely studied field. e.g.:
The reason it's so fascinating though, is that because it is a many-variable optimization problem where 1) many of the variables conflict and 2) we haven't actually agreed on the desired optimum. In the end it still very much has a "you know it when you see it" quality, and nobody has come up with math that definitively says "yes this is" or "no this isn't".
Actually, it's maybe a little like spam filtering.