Yes, an extension cord will work perfectly fine.
Alternatively, you can use a USB-C power supply and longer USB-C cable. You can both the USB-C charger and 3m or 5m long USB-C cables online (ie Amazon, ebay) or at an electronics store etc etc...
Or if you have a laptop power supply with a USB-C plug...which is fairly common on relatively modern windows laptops supplied by Dell, HP, Lenovo, Huawei, LG, Acer, Asus etc etc...