Is is safe to use WD40 as a matte paint protector for a carbon bike?
There's not really a generic answer as not all finishes will react the same way to a given chemical, especially over time with repeated application. WD-40 has a bunch of naptha, which generally speaking you want to keep away from paint you care about. It also leaves an oil coating behind that can attract dirt, which is ugly and potentially bad for the finish by itself.

Just use one of the many silicone cleaner/wax/protectant products. Silicone is good because its whole deal is it doesn't harm any finish type on bikes, regardless of specifics.