This should all be doable. To answer each question...
For flashing ditchlights, realistically you need 2 outputs. Technically you can do it with 1 output by wiring the output to a circuit that would flash the lights (like a grade crossing flasher circuit), but I'd hate to try and have to fit that inside the loco as well. Best to just use 2 outputs.
So, for the F40PH your setup could go like this:
Output 1: Front headlight + Numberboards (2 LED's)
Output 2: Left ditch light (1 LED)
Output 3: Right ditch light (1 LED)
Output 4: Marker lights (2 LED's)
Output 5: Mars light (1 LED)
Output 6: Cab + Step lights (2 LED's)
All of those LED's on at the same time should not be a problem (it's only 180mA across all the outputs on the basis of 20mA for each LED. You will actually need much less than this) if you plan everything out first.
For the cab car and coaches, this should also be doable. I'd definitely go the route you suggested with the coaches, with their own power pickups; you don't want to try and power all the cars from one LM. This is what I see.
Output 1: Headlight
Output 2: Marker lights
Output 3: Interior lights / link to coach lights?
Output 4: Class lights 1 / link to coach class lights 1
Output 5: Class lights 2 / link to coach class lights 2
Output 6: Class lights 3 / link to coach class lights 3
The best way to accomplish this (as stated you don't want to try and power all the lights in the coaches from one LM) is for each output going to each coach to turn on something like a relay (we can do better than a relay I'm sure) that supplies the coach interior lights / class lights from the onboard pickups. If I had time today I'd do a drawing of what I mean.
The SW, All of that is doable too. Most DC and DCC ready loco's (well here anyway) already feature this type of thing with front headlight/rear markers on/off , rear headlight/ front markers on/off. Usually some sort of diode steering is involved. I'd have to get one of the circuit boards I've got laying around to see.
All in all, as long as you don't run out of outputs and you don't hook too many LED's up to each output (we do have what each output is rated for here on RPUG somewhere) then anything should be possible.
- Tim