It's not strictly illegal, but it's against Federal ethics rules.
The problem is, punishment is exclusively up to their superiors. Which, here, is the President.
Kellyanne Conway did this in the first Trump admin. No real consequences then, either.
https://www.nytimes.com/2017/02/14/us/politics/Kellyanne-Con...
> Federal ethics rules on conflicts of interest specifically exempt the president and vice president. But for any other executive branch employee, the rules prohibit using public office for personal gain, or “for the endorsement of any product, service or enterprise, or for the private gain of friends, relatives or persons with whom the employee is affiliated in a nongovernmental capacity.”