I use 3 USB keyboards with my band, connected to a PC, and the keyboards are automatically installed ad MIDI inputs under Windows. I don't know what Yamaha keyboard you use (exact model?) but I doubt you can do the same with any Arduino or ESP32, because the USB to MIDI conversion is handled by the Windows plug-n-play drivers.
But you can use the standard MIDI port (it's a serial port after all, set to a specific speed 31250 baud....)., so you don't actually need any specific Arduino or ESP32.
MIDI connection is pretty straightforward, especially because you need just to connect a MIDI OUT (or TX pin) from Arduino to MIDI IN of the keyboard.
Here is a basic description of a MIDI OUT connection from Arduino:
To make things easier you could get one of the Arduino MIDI shields available.