You would have to build a spaceship close to the size of the Earth or make the magnets inside of it strong enough for the flux to cover a very large portion of the earth. Now let’s say you could build a power source that could supply a massive amount of power to make this magnetic field (like the power source tony stark of iron man created) as soon as you applied the power the current would shoot up so high that the wires would vaporize instantly, but let’s say somehow we invented a wire and components that could handle this massive current, and could generate this magnetic field. The magnets would pull the ship to the nearest metal object(s) and would be impossible to pull off; it would also draw every metal object from miles away, It would soon be covered by miles of metal killing everyone and everything in the immediate location including the people inside the ship.
I am not sure how you could avoid these problems unless you use it a safe distance away from anything metal including a metal spaceship, but I also believe that if the field is intense enough magnetism will have an influence on any object, as shown on TV where it was shows that you can levitate a frog in a super strong magnetic field (A magnetic field nowhere close to the strength this spaceship would need to generate.) so, at our current state of technology, I would have to say no. But, why does it have to be magnetism. Why not anti-gravity? I have no idea how that would work, so I could not think up ways to dispute it, like I can with magnetism.
I saw a film where scientist levitated an object using high voltage. this is something has actually been done. It would be more practical to do it that way instead of using magnetism.