If you look at “/opt/nvidia/l4t-usb-device-mode/” you will find some sample device mode scripts. These scripts basically show you how to use the Linux “gadget” framework. The gadget framework is actually documented within the kernel docs, and on the internet, but the gist is that certain more or less standardized devices have their frameworks built and you simply fill in some details.
Another option is to write a driver from scratch.
Do note that in device mode Jetsons do not support isochronous transfers (others are supported, e.g., interrupt or bulk).