The short answer is: Yes, it can be done.
A better answer would be: I'ts not likely to make economic sense. As a general rule, the cheapest way to buy bicycle components is already bolted onto a frame. By the time you change out the whole drive train of your bike, you will probably have spent quite a bit more than a different bike would have cost you. Old, lightly used road bikes are pretty much a dime a dozen. Find one that's the right size and that's set up the way you want and buy it.