Some moduli spaces of sheaves, like Hilbert schemes of points on a Calabi-Yau threefold, are known to be *globally* expressible as degeneracy loci of a regular function on a smooth variety. If I am not mistaken, any moduli space of sheaves on a CY3 is *locally* a degeneracy locus.
My question is: does there exist a criterion for such a moduli space $M$ to be globally expressible in the form $$M=V(df)\subset Y,$$ for some regular function $f:Y\to \mathbb A^1_\mathbb C$ on a smooth variety $Y$?

I was also wondering whether the question becomes easier if $M$ is a closed subscheme of a moduli space $H$ which itself *is* a global degeneracy locus. For instance, I would be interested in closed subschemes $M\subset H=\textrm{Hilb}^nX$, where $X$ is a CY3: is it known, at least in some special cases, whether these are global degeneracy loci?

Thanks for any suggestion.