Yes. You can do it with one relay. In this case, you can use an A-C relay, and do not need to provide D.C or a slow-release capacitor. Or you can use a D-C relay and a diode.
You will need to create 2 separate insulated outside rail sections in the mainline track approaching the switch. Call them A and B. They need to be separated by one regular section of track.
The first one (A) goes in front of the track switch, about three sections before the switch, and is wired in parallel with the anti-derail section of rail on the switch itself. That will create the impulse that will swing the switch to the diverging route. We will call the wire that interconnects the insulated rail A and the diverging route switch coil the "diverging wire"
The other insulated track section (B) goes between section A and the switch, also in the main line. Section B is wired to a relay ("B") that will operate whenever a train is on section B. One side of the relay coil goes to section B and the other side of the coil goes to a constant hot post on your transformer.
Relay B has one break (normally closed) contact in series with the diverging wire.
Sequence of Operation:
Train approaches switch, and A section throws the switch to the diverging route.
Train travels around the loop, and approaches the trailing end of the straight entrance to the switch.
The anti-derail feature of the switch senses the train, and throws the switch automatically to the straight direction.
The train now travels across section B and operates relay B.
The break (normally-closed) contact of relay B in series with the diverging wire now opens the diverging wire, and prevents the diverging choice from happening until the last car of the train leaves the interlocking, at which time the switch is thrown back to the diverging route. This prevents the exiting train from "picking" the switch.
You can also do this with a 153C contactor, if you don't want to use a relay, but your operation will be more precise with the relay.
>direction of travel>------- section A------- regular section--------section B---------switch (diverging track)-----------loop----------entrance to straight side of switch-----------section B (again) --------- section A (again) ----------> exit the interlocking, train goes to the other end of the layout-------->