... like how they colour margarine (well, not in the UK IIRC, it's illegal there)
No it isn't (not now anyhow), but as with all foods sold for human consumption only permitted colouring agents (e.g. carotene) may be used. This is an EU-wide thing. Where margarine colouring is or was banned this was because the dairy industry didn't like the competition and wanted to put margarine, which is naturally coloured white, at a disadvantage. At one time dyeing margarine yellow was allowed in 26 US States and forbidden in the others. Kraft used to sell a Parkay margarine in two versions: yellow for those 26, and white for the rest, with a little sachet of yellow dye included. The purchaser had to put the margarine in a plastic ("Color-Kwik") bag together with the dye and knead the contents to spread the colour evenly. In fact there were federal restrictions on margarine until 1950. Wisconsin, the cheese state, was the last anti-margarine hold out (till 1967).
In the UK, I don't know about elsewhere, you can buy deep yellow products which are butter/margarine mixtures with names like "Utterly Butterly" and "I Can't Believe It's Not Butter" "Better'n Butter", "Heavenly Butterly" etc, and in fact some butter is dyed to make it more appealing. At home we use a spread made with olive oil and milk whey called Olivio.
The lady in the lower picture looks like she's been rubbing the dye in her hair...