We investigate the non-equilibrium large deviations function of the particle densities in two steady-state driven systems exchanging particles at a vanishing rate. We first derive through a systematic multi-scale analysis the coarse-grained master equation satisfied by the distribution of the numbers of particles in each system. Assuming that this distribution takes for large systems a large deviations form, we obtain the equation (similar to a Hamilton-Jacobi equation) satisfied by the large deviations function of the densities. Depending on the systems considered, this equation may satisfy or not the macroscopic detailed balance property, i.e., a time-reversibility property at large deviations level. In the absence of macroscopic detailed balance, the large deviations function can be determined as an expansion close to a solution satisfying macroscopic detailed balance. In this case, the large deviations function is generically non-additive, i.e., it cannot be split as two separate contributions from each system. In addition, the large deviations function can be interpreted as a non-equilibrium free energy, as it satisfies a generalization of the second law of thermodynamics, in the spirit of the Hatano-Sasa relation. Some of the results are illustrated on an exactly solvable driven lattice gas model.