Hmm. I have played around with this a bit. I think if you are using safe mode of necessity then you simply can't use lilypond for this use case. Sooner or later you have to mix Lilypond and Scheme, and it is forbidden in safe mode.
Transforming the code for the cut from the repo in question, I came up with this:
But under safe mode Guile throws errors, in accordance with the NR statements.
At this point, we need to turn to greater experts than me. I am sure that my posting this weak code above will stimulate somebody of greater knowledge to show if this really is possible.
In the meantime, the set of Larsen ornamentation glyphs is a really nice library if one is using it in a 'normal' context.