Yes, it’s legal, because the fighter has a possible landing space. Remember, the rules say that in order to determine a possible landing space, you may assume that all of your rolls will be hits and all of your opponent’s rolls will be misses.
If by some miracle the sub defeats the battleships, the carrier must move to pick up the fighter. In the more likely event that the sub loses, the carrier may not move to the sea zone, as the move would be illegal (the sea zone would remain hostile), so the fighter will have no place to land and will be lost.