Can two captains fly an airliner?
Yes. 

What allows you as a pilot to fly large aircraft (legally under the FAA) is a type rating. As long as the two Captains hold proper type ratings for the aircraft they suffice for the required two crew members needed to fly the plane. However one of the two of them will be performing the duties of the first officer and that should be decided prior to the flight. 

First Officer and Captain are rankings given by the airline not any governing body. Both the FO and Captain cary the type cert required to fly the aircraft (as far as I know).

The limited (and quickly dwindling) exception to this is aircraft that require a crew of 3 where the third is a flight engineer. The Flight Engineer position does hold its own certification.