Completely ignoring moral and ethical considerations, only answering in generic legal terms. It depends on the contract formed when ownership/control of the loco was passed. If full ownership was freely given without any conditions, they can do more or less anything they want with it (scrap, sell, turn it into a garden ornament, lease it to a TOC, etc). On the other hand, the donating company can put any conscionable restrictions into the transfer that they want to, which would be legally binding if made clear at or prior to the point of transfer.
Just my informal opinion, certainly not to be taken as formal legal advice.