Yes, you can physically replace the ECM yourself, but the vehicle probably wouldn't even start.
The ECM has to be programmed with the vehicle's original VIN and mileage.
Sorry, but you'll have to have a dealer do it, if it is a new ECM.
As for a used one.
It is possible that you could get a used one and the vehicle might operate, but you would still need to have a dealer reprogram it and you would want them to install it, so that there wouldn't be any hassle about setting the mileage to what your vehicle has now.
That being said, there are some ECM rebuilding places that might be able to send you a programmed ECM using your VIN and current mileage information. Be prepared to pay in the neighborhood of $600+ for one though.