A U.S. foreign-development agency intended to counter Beijing’s dollar diplomacy is lending $500 million to build a solar-panel factory in India, putting American taxpayer money behind a bid to weaken China’s dominance of the solar industry’s supply chain.