How to make a custom referenceable "Lecture" element and include its date in the outline?

Of note, this doesn’t have much to do with the label syntax you’re using, it’s just that you need to be in markup mode to attach a label; they’re special-cased. That is, #{ figure(...) <lbl> } won’t work but #[#figure(...) <lbl>] will.

Typst 0.12 will have a more useful hint when this generates an error (see Improve error message for labels in code mode · Issue #4317 · typst/typst · GitHub).