No, you cannot castle your way out of check. As long as your king is attacked, you don't have the right to castle.