A federal judge approved an emergency $300 million loan that will keep Puerto Rico’s troubled electric utility in operation, averting a threat of more power outages at a time when the island is trying to recover from last summer’s devastating hurricanes.