Alphabet Inc.’s Google and Amazon.com Inc. have found an avenue to profit from Elon Musk’s chaotic Department of Government Efficiency.