According to Lemma 1 in https://en.wikipedia.org/wiki/Chern%E2%80%93Weil_homomorphism#Definition_of_the_homomorphism , if $\Omega$ is the curvature of a connection on a principal $G$-bundle $P\xrightarrow{\pi}M$, then for any $G$-equivariant ((real/?)complex-valued) polynomial $f$ on $\frak{g}$, there exists a unique 2-form on $M$ which pulls back to $f(\Omega)$.
Does anyone have an explicit counter-example showing that $\Omega$ itself need not be the pullback of any ($\frak{g}$-valued) form on $M$?
Edit: following the suggestions of the comments below, I realized the connection itself can't be a pullback since it doesn't vanish along the fiber directions (whereas the curvature does).