Can one pilot lock the other out of the cockpit?
Yes, see the Ethiopian Airlines hijacking in February 2014.

From this BBC article about MH370:


  The security of the cockpit door offers protection against intruders, but it also prevents action being taken if something does go wrong. Last month the co-pilot of an Ethiopian Airlines flight waited for the pilot to go to the toilet before hijacking the aircraft and flying it to Switzerland. 


As for higher authority codes, from the same answer you linked to:


  Even if the stronger code is entered that will open the door the pilots still have some time to cancel the unlock request.


Meaning that if a pilot is willfully locking the other out of the cockpit, there is no way for the other to regain access to the cockpit.