A topologically twisted index for three-dimensional supersymmetric theories