Aircraft registration numbers are assigned by the country where the aircraft is registered. Each country has a prefix (see the full list on Wikipedia), like e.g.
D- for Germany. The prefix is usually separated from the rest by a dash, but some countries deviate from this, most notably the United States, where registration numbers begin with
Whether or not custom registration numbers are available depends on the country. In Germany, the authority in charge of assigning registrations is the Luftfahrtbundesamt. It is possible to ask for a custom registration number via the form Antrag auf Vormerkung eines Kennzeichens (§ 19 Abs. 2 LuftVZO). The fee is currently 30 Euros. In order to get the custom registration, it must be available of course, but also follow these rules:
D-AAAA to D-AZZZ for aircraft with more than 20 t MTOW
D-AUAA to D-AZZZ (test registrations) for aircraft manufactured by Airbus at Finkenwerder
D-BAAA to D-BZZZ for aircraft with 14–20 t MTOW
D-CAAA to D-CZZZ for aircraft with 5.7–14 t MTOW
D-EAAA to D-EZZZ for single-engine aircraft up to 2 t MTOW
D-FAAA to D-FZZZ for single-engine aircraft from to 2–5.7 t MTOW
D-GAAA to D-GZZZ for multi-engine aircraft up to 2 t MTOW
D-HAAA to D-HZZZ for rotorcraft
D-IAAA to D-IZZZ for multi-engine aircraft from 2–5.7 t MTOW
D-KAAA to D-KZZZ for powered gliders
D-LAAA to D-LZZZ for airships
D-MAAA to D-MZZZ for powered ultralight aircraft
D-NAAA to D-NZZZ for non-powered ultralight aircraft
D-OAAA to D-OZZZ for manned free balloons
D-0001 to D-9999 for gliders.
So it was at least in part luck that
D-ICEY was available and fit the rules for a Cessna Citation.
In the UK, the authority in charge is the Civil Aviation Authority (CAA), which also allows custom registrations (called out of sequence here). The fee is currently £158.
This answer explains the procedure for the US and Canada.