Here is a clever bit of code by James Mitchell (aka monkeymademe on GitHub) that will autoflash a Raspberry Pi Pico when you plug it in.