Can a YAML preamble be defined not at the start?

Sometimes, there are things I’d like to put first.

No, CommonMark doesn’t say anything about preambles or frontmatter or Yaml. If your system doesn’t handle it separately, something like the following will be rendered as a horizontal rule followed by a heading:

---
foo: bar
---
Lorem ipsum.
1 Like