Beyond line-of-sight (BLOS) communications are used all the time with satellites and other relays so people can communicate with others outside their immediate LOS. You need relays that extend the visibility of the planets with respect to each other. This is non-trivial, but not much harder than the work already going on to land things on Mars that requires (or desires) comms back to Earth.