Regarding your German link. It's about tampering with evidence which I suppose means it's about changing the IMEI after a crime to hide yourself. I suppose that would be illegal everywhere?
Regarding your UK example, the law in question (https://www.legislation.gov.uk/ukpga/2002/31/section/1) mentions circumstances and gives exceptions:
" But a person does not commit an offence under this section if—
(a)he is the manufacturer of the device, or
(b)he does the act mentioned in subsection (1) with the written consent of the manufacturer of the device. "
So I guess it's okay in the UK if the manufacturer allows it and is okay with it?
But of course I'm not trying to promote this feature for illegal use but mostly to hinder "inescapable" tracking from Advertisers , Mobile Operators, ISPs, Phone Manufacturers and ...