Why is the work done by a gas during free expansion zero and not infinity?
The external pressure in space is 0 (well, depends where and not quite, but for the discussion let's say that it is). So $P \cdot \Delta V$ is also 0. Gas expanding from a hole in a spaceship is not an irreversible process. Such processes are very slow and gradual, such that the external pressure has time to equilibrate with the internal pressure.

On the contrary - you have the most irreversible process in here. Gas leaking from a hole in a spaceship into a medium (space) that will never equilibrate with the internal pressure.

Think about it from an intuitive point of view. Work done by an expanding system is there because it moves other things around. In space there is nothing to move, so no work done.