Let's assume we are working over $\mathbb{R}^n$ (but feel free to change to domain to answer the question). I wish to know if the equation $F = dA + A \wedge A$ can be solved for a matrix of $1$forms $A$, given a (smooth) matrix of two forms $F$ which satisfies the condition $dF =B \wedge F  F \wedge B$ for smooth matrix of oneforms $B$ (i.e. the Bianchi identity is satisfied). Notice that this is true for linebundles (in fact over any convex open set).

The answer is generally 'no'; for most $F$ that satisfy your condition, there will not exist an $A$ that satisfies $F = dA + A\wedge A$. The easiest counterexample I know of is when $n=4$ and the matrix $F$ is $2$by$2$. To begin, note that you can reduce to the case when both $F$ and the $A$ you seek have trace zero, i.e., they take values in ${\frak{sl}}(2,\mathbb{R})$. (The reason is that the problem breaks into the part of $F$ that is a multiple of the identity matrix and the tracefree part. I'll leave the details to you.) One can easily check that, for the generic ${\frak{sl}}(2,\mathbb{R})$valued matrix $F$ of $2$forms on $\mathbb{R}^4$, the kernel of the mapping $C\mapsto F\wedge C  C\wedge F$ from ${\frak{sl}}(2,\mathbb{R})$valued matrices $C$ of $1$forms on $\mathbb{R}^4$ to ${\frak{sl}}(2,\mathbb{R})$valued matrices of $3$forms on $\mathbb{R}^4$ is zero. By dimension count, it follows that this mapping is surjective as well. Thus, for a candidate ${\frak{sl}}(2,\mathbb{R})$valued $2$form $F$ that satisfies this open genericity condition, the equation $dF = F\wedge B  B\wedge F$ is always solvable for $B$, and, moreover, the solution is unique. Thus, this $B$ is the only possible candidate for $A$. Heuristically, this makes it almost immediate that, for the generic such $F$, the $B$ that you find will not satisfy $F = dB + B\wedge B$. The reason is that ${\frak{sl}}(2,\mathbb{R})$valued $1$forms on $\mathbb{R}^4$ depend on only $3\times 4 = 12$ arbitrary functions of $4$ variables while the generic ${\frak{sl}}(2,\mathbb{R})$valued $2$form $F$ depends on $3\times 6 = 18$ arbitrary functions of $4$ variables. There is no chance that you could hit each such $F$ with an $A$. To construct an explicit example, choose an ${\frak{sl}}(2,\mathbb{R})$valued $1$form $A$ such that $F = dA + A\wedge A$ satisfies the genericity condition. Then, of course, $2F$ will satisfy this genericity condition as well, and, since it satisfies $d(2F) = (2F)\wedge A  A \wedge (2F)$, it follows that the only possible $1$form whose curvature could be $2F$ is $A$. However, the curvature of $A$ is $F\not=2F$. Thus, $2F$ satisfies your condition, but it is not a curvature form. 

