is it somehow possible to connect the Core2 to a Serial Console to get print statements?
with something like that:
Serial pc(USBTX, USBRX);
Yes, you can use mbed with CORE2. Your example will enable serial interface on CORE2’s micro usb. Do you have any problems with that code? Also for more details on how to use serial refer to official Mbed OS documentation.