We assume $G$ is a compact connected Lie group with Lie algebra $\mathfrak{g}$. Let $\rho:\mathfrak{g}\to \mathrm{End}(E)$ is a finite representation.
We denote by $\underline{E}=G\times E$ the trivial bundle over $G$. Take $U\in \mathfrak{g}$, then $U$ define a left-invariant vector field $X_U$ on $G$.
For $s\in C^\infty(G,\underline{E})$, we define the $G$ action by, $(g\cdot s)(x)=s(g^{-1}x)$. Take $e\in E$, then $e$ define a $G$-invariant section $s_e$ of $\underline{E}$, that is $s_e(x)=e.$
We define a connection on $\underline{E}$ by $$\nabla_{X_U}s_e=s_{\rho(U)e}.$$ This is a flat connection. The $G$-invariant part of the de Rham cohomology associated to this flat bundle $(\underline{E},\nabla)$ is what you are looking for in comment 2, i.e., $$\Big(H^\cdot_{dR}(G,\underline{E})\Big)^G=H^\cdot(\mathfrak{g},E).$$
To show this, we identify $\Omega^\cdot(G,\underline{E})^G$ the left-G-invariant differential form with coefficients in $\underline{E}$, with $\mathrm{Hom}(\Lambda^\cdot(\mathfrak{g}),E)$. Under this identification, The de Rham differential operator $d$ become the differential of the complex $\mathrm{Hom}(\Lambda^\cdot(\mathfrak{g}),E)$. This means $$H^\cdot(\Omega^\cdot(G,\underline{E})^G,d)=H^\cdot(\mathfrak{g},E).$$
We apply the Hodge theorem. We denote by $\Box$ the Hodge Laplacian, we get $$\Omega(G,\underline{E})=H_{dR}^\cdot(G,\underline{E})\oplus \mathrm{im}(\Box)$$ Since $\Box$ commut with $G$, we have $$\Omega(G,\underline{E})^G=H_{dR}^\cdot(G,\underline{E})^G\oplus \mathrm{im}(\Box)^G.$$ From this twolast equation, we get $$H_{dR}^\cdot(G,\underline{E})^G=H^\cdot(\Omega^\cdot(G,\underline{E})^G,d).$$