A milling machine can cut a hexagonal hole, but the inside radius at each corner cannot be smaller than the radius of the cutter. A 4mm hex hole would require a tiny cutter to do a good job. Here's that process for a larger hole.[2]
If the hole goes all the way through, just get a hexagonal punch. Might need to drill a round hole first.
Or just buy a 4mm socket with a T-handle. Cost US$4.99.[3]
[1] https://www.youtube.com/watch?v=_AYEFjbGaL4
[2] https://www.youtube.com/watch?v=zOqSIRuBgCY
[3] https://www.amainhobbies.com/rc4wd-metric-hex-twrench-tool-4...