How can I use Raspberry Pi 3 as a USB gadget. Is there any way?
How can I enable the USB gadget mode on Raspberry Pi?
You cannot use the Raspberry Pi 3 as a USB gadget. At the time of writing this is only possible on the Raspberry Pi 0, 0W, A, A+, and 4. The Pi B, B+, 2, 3, 3A+, and 3B+ lack the required pin for OTG.
If you have a Pi Zero, this gist has some examples that work with minimal configuration like
g_multi. For example, a minimal way to enable the serial gadget is to add
dtoverlay=dwc2 to /boot/config.txt and
g_serial to /etc/modules
lukas2005's original answer linked to iSticktoit.net's 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 micro-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.