Of course you can. The only problem is it will be heavier than you need, and it will tend to get pinched between the tire and rim and will blow out if everything isn’t tucked inside, carefully so you don’t make a hole. But there’s no problem with safety.
That’s fine… half the time the tires aren’t the size they say they are anyways +/- 2mm. I tend to lean the other direction though, using a tube that is smaller (primarily due to potential problems mounting the tire without a puncture).