The operator $D$ in (1) is the related to (odd part of) the de Rham operator $d+d^*$. If you omit the Hodge star in the last term, you end up in $\Omega^0\oplus\Omega^2$. The Atiyah-Singer index (or if you like, the twisted Gauß-Bonnet theorem) theorem gives
\begin{align*}
\operatorname{ind}(D)&=-\operatorname{ind}(d+d^*\colon\Omega^{\mathrm{even}}(\Sigma;\mathfrak g)\to\Omega^{\mathrm{odd}}(\Sigma;\mathfrak g))\\
&=-\int_\Sigma e(T\Sigma)\,\operatorname{ch}(\mathfrak g)\\
&=-\int_\Sigma e(T\Sigma)\,\dim\mathfrak g=-\chi(\Sigma)\,\dim\mathfrak g\;.
\end{align*}
The Euler class is homogeneous of degree $\dim\Sigma=2$, hence only the zero degree term $\dim\mathfrak g$ of the Chern character survives. In particular, this index does not see if the principal bundle $P$ is nontrivial.