With all the right parts and lots of money it should be possible. Be aware that BMW probably also had a different suspension for the 540.
You can, but you'll need a new wiring harness, transmission and steering rack (recirculating ball) to start. Also, getting a reliable m62tu is not cheap, unless you want to risk it with a junk yard engine. There are quite a few suspension differences including struts/shocks as Full_of_Regrets mentioned.
Search BMW 5 Series Questions
BMW 5 Series Experts
Related Models For Sale
Used Cars For Sale