In certain circumstances it can, but it's far from certain and it's much easier (and cheaper) to stop a foreclosure before it happens. In a U.S. Supreme Court case called BFP v. Resolution Trust Corp. (1994), the Court ruled that a non-collusive, regularly conducted foreclosure sale could not be challenged as a "fraudulent tranfer" under Section 548 of the Bankruptcy Code.
But recently a Houston bankruptcy judge ruled that a debtor in bankruptcy can challenge a foreclosure as a "preference" under Sections 522(h) and 547 of the Bankruptcy Code. The debtor had argued that Wells Fargo (as transferee) received more via the judicial foreclosure sale than it would have received in a hypothetical chapter 7 case in which the prepetition transfer did not occur.
This case is not over yet, but at least the Court did not throw the case out on "summary judgment." if you have already been foreclosed on, we will consider taking your case, but we can't make any promises. Best bet: stop the foreclosure with a bankruptcy filing before it happens.