Mr. Weiner, one of Congress’s most enthusiastic users of social media to engage with constituents and supporters, said he believed his Twitter account, or a related photo-sharing site, had been infiltrated by a hacker or a prankster, who had then sent the offending photo out late Friday.