building a phone from parts is of course possible, you can start with a naked pcb and put all the smd parts on it - that is not really the problem - surely - depending on the phone, it could make some trouble to program it. the imei can be a problem - but that depends on your hardware/software/knowledge.
the imei has nothing to do with the carrier - the imei is a number that combines the country of origin, the manufacturer and a serial number, it closes with a checksum.
in many modern devices - the imei is not changeable - for a "regular user" with a data cable - but when you have the right hardware - you can do many things - many phones were "modified" with a jtag interface and the right voltage.
anyhow - it's possible to rebuild (or even fake) a phone - thats why there are blank iPhone pcb's on the chinese market ;-)