The way the electromagnetic Lagrangian is usually constructed is by noticing that the EM fields are always constrained to satisfy ${\rm d}F=0$ (half of Maxwell's equations). We can immediately solve this constraint equation through $F={\rm d}A$. Then the following action,

$$ S[A,{\rm d}A] = \int {\rm d}A \wedge \star {\rm d}A, $$

leads to the remaining Maxwell's equations.

That's fine, but I want an action where $F$ is the dynamical variable and the constraint ${\rm d}F=0$ isn't solved a priori, but rather follows by introducing a Lagrange multiplier $\lambda$. Concretely, I want an action of the form,

$$ S[F,{\rm d}F,\lambda]=?, $$

such that:

  • From varying $F$, we get the equation of motion ${\rm d}\star F=0$.
  • From varying $\lambda$, we get the equation of motion ${\rm d} F=0$.

Is such a thing possible?

EDIT: The linked answer doesn't satisfy my demands. While it derived ${\rm d}F=0$ by varying a Langrange multiplier, which I'm allowing, it also derives the equation of motion ${\rm d}\star F=0$ by varying a Lagrange multiplier. I do not want this. The eom should come by varying $F$.