Julian Assange, the founder of WikiLeaks, agreed to plead guilty in a U.S. case against him, ending a yearslong legal battle that raised concerns about the sanctity of press freedoms.