Can CH3COOH be written as C2H4O2?
$\ce{C2H4O2}$ is the molecular formula of acetic acid. As such, it's a correct method to write the molecule. However, you should note that, as Ivan Neretin mentioned, molecular formulae are not necessarily unique for a given molecule.