I will give a more detailed example in few days, but I can confirm it works.
import hbs from 'discourse/widgets/hbs-compiler';
import { createWidget } from "discourse/widgets/widget";
export default createWidget("foo", {
template: hbs`
<p>MY TEMPLATE</p>
`
});
Used in a post with [wrap] and WidgetGlue: