In case somebody is facing the same issue: it seems to be caused by using a 3rd party USB-C to USB adapter. It caused when loading code to the Arduino Mega 2560 avrdude reporting a timeout.
It worked well using an Arduino Uno, but not with the Arduino Mega2560 (rev. 3). It worked sometimes when the Arduino Uno was connected first to an USB port uploading and the the Mega was connected to the second USB port of my adapter (dodo cool 7-in-1 multiport hub with dual USB-C connectors to the Macbook). I'm using an Apple M1 MacBook Air. Arduino IDE software was 1.8.16.
How did I solve it ?
After various tries only way to fix it was to use an original Apple USB-C to USB adapter.
I hope it helps !