You cannot use the Raspberry Pi 3 as a USB gadget. At the time of writing this is only possible on the Raspberry Pi Zero, Zero W, and classic Pi model A/A+. The Pi B+, Pi 2, and Pi 3 lack the required pin for OTG. If you have a Pi Zero, [this gist](https://gist.github.com/gbaman/50b6cca61dd1c3f88f41) has some examples that work with minimal configuration like `g_serial`, `g_ether`, or `g_multi`. I'm surprised lukas2005's answer got downvoted. iSticktoit.net has good examples of using the more modern ConfigFS approach. The keyboard HID example is a good one to start with. And when you have only one functional USB port, it becomes particularly valuable to configure multiple gadgets at a time, something that is not as readily available with the old `g_*` kernel modules.