There is an
earlier suggestion to produce an artificial magnetic field with superconducting coils at the surface - for Earth, but adaptable to Mars. Putting coils at L1 is an interesting approach as well.
The Sun/Mars L1 point is 1,070,000 km away from Mars. This is far away from the tiny moons (Deimos 23,000 km, Phobos 9,400 km semi-major axis). They might be used for building materials, apart from that they are not relevant.
The solar wind would lead to some force on the magnetic field, but this force is small compared to the radiation pressure a solar sail would experience. At 1 AU, it is typically 1-6 nPa, at 1.5 AU it is about half that. Multiplied by pi*(Mars radius)^2, we get 20 kN - 100 kN, maybe more if we want to shield a bit more.
A superconducting coil would probably have a mass of at least a million tons. Pressure from solar wind would be a small, but not negligible contribution to the force balance. Just put it a bit closer to the Sun than L1.
In space, and at 1.5 AU, a superconducting coil could be cooled passively. It would put itself into a circular shape itself as soon as current runs through it.
I would expect the orientation of the coil to be stable, but a small rotation could be added if that is wrong. The position would be more challenging, as L1 is unstable. Maybe the interaction with the solar wind can be used.
If it fails, Mars continues losing atmosphere at a tiny rate. Even a 100 year break in its operation wouldn't have notable effects. Which also means it makes no sense to start building something like this in the 21st century. This is something that could become interesting in thousands of years, if humans are still around then.