Power and Data
The classic solution to this for model trains is Digital Command Control (DCC). Basically, when you provide power over the rails, you also include a data signal riding on top of it. Each locomotive or car with a remote controlled function needs an electrical connection to the track and a modest microprocessor to decode DCC instructions. You can do something similar with LEGO trains, but it requires some customization.
For example, here's a modification that I made to one of my 9V motors to include a small microprocessor that controls the wheels instead of driving them directly:
This solution requires that you are using either 9V or 12V powered rails, and is also very expensive as it requires a number of motors that are no longer in production and are expensive on the secondary market.
Assuming that you are just powering a few LED lights in your cars or perhaps a small unloading mechanism that is used infrequently, you can probably get away with using a small lipo or similar battery for your cars. In that case, you just need to figure out a way to get access to control data.
If you just need one way data, you could use a very basic RF receiver/transmitter pair (e.g. receiver, transmitter). This gets tricky to scale up, as you need a separate frequency and transmitter for each car, but could work with a small number of controlled cars.
The solution that I would probably use if I were trying to do this would be to put an ESP8266 in each car:
These parts are quite cheap ($2 - $5) USD, can consume very little power if programmed properly, and provide a ton of flexibility. They provide and 80 MHz CPU and connect to Wifi networks, so you can control everything from a computer if you'd like. They also provide plenty of I/O pins and are more than fast enough for PWM, so you can have fine-grained control of everything and integrate sensors into locomotives and cars if desired.