I've tried my hand on it, but couldn't make it work. Should be very similar to the functionality already offered by the filter. Calling convert works like this: magick convert [input-options] input-file [output-options] output-file, so all that needs to be done is to grab that output file, maybe by providing a temp file location. Here are two code snippets for experimenting:
(without input file, creates a png with the letter "a")
convert -size 300x300 xc:white -gravity center -pointsize 150 -annotate 0 "a" output.png
(with input file, combines the images b.png and c.png on top of each into a new image and draws a red box around it)
b.png c.png -append -bordercolor red -border 6