How to prioritize a current path in a circuit
You can build a circuit that behave as you say. Basically, you need a small shunt resistor that measure the total current consumed by both device, a P-channel mosfet that will limit the power provided to device two, and an opamp inbetween that adjusts the gate voltage of the mosfet depending on the total current (i.e. that will shut down gradually the mosfet as the total current reaches the maximum).

The thing is: such a monitoring circuit can only work if you have a resistive circuit as device two (e.g. a set of lights). However, a battery charger is an active circuit. It will probably not work at all if the voltage is below a given limit. So in the end, this will not work for your application, or be completely unstable (when the battery charger uses too much current, the monitoring circuit will shut down the mosfet a little bit, leading the battery charger to go undervoltage, so it will shut down, not using any current at all, then the monitoring circuit will rise again the battery charger voltage, which will draw too much current, etc...).

The only way is to be able to tell the battery charger how much power it can suck. So, either you find a battery charger designed with this capability, or you have to design your own.