WASHINGTON — A federal judge sharply rebuked the National Security Agency in 2011 for repeatedly misleading the court that oversees its surveillance on domestic soil, including a program that is collecting tens of thousands of domestic e-mails and other Internet communications of Americans each year, according to a secret ruling made public on Wednesday.