Justice Juan M. Merchan thwarted one of several attempts by Donald J. Trump to clear his record of 34 felonies before returning to the White House.