An Algebro-Geometric Approach to Twisted Indices of Supersymmetric Gauge Theories