They have a pretty decent explanation at
https://developer.android.com/develop/ui/compose/touch-input/stylus-input
with code and everything. I haven't done it yet but looking into it and the hardest part seems to simply be putting it all together.
E.g., more specifically:
https://developer.android.com/develop/ui/compose/touch-input/stylus-input/ink-api-draw-stroke