WASHINGTON—The Trump administration slapped Moscow with its first sanctions for meddling in the 2016 presidential campaign and waging unrelated cyberattacks on critical U.S. infrastructure, punishing the Kremlin’s intelligence agencies and Russians already indicted by special counsel Robert Mueller.

In sanctioning five entities and 19 individuals Thursday, the Treasury and senior national-security officials accused the Russian government of ongoing attacks on the U.S. energy grid, and water, aviation and manufacturing facilities....