There are solutions on the market, but they are expensive and don't always fit the look of your bike. Plus if you could afford to spend the money, you probably just bought a more expensive bike computer with a bigger or with a rotational mount.
The second picture shows what was inside the package of my speedometer.
For this project you will need:
rotary tool (Dremel)
Speedometer magnet & sensor
(If you don't own a dremel you can always make due with a candle and a box cutter to make the holes.)
Step 1: Decide where you want to install your speedometer
Find a zip tie that is big enough to fit around either the handlebars or stem of your bike.
Plan where you will fit the sensor on the front fork, and how you will route the wire to the sensor. Like most people, I will guide the wire alongside my brake-cable.
As you can see in the picture, the mount for my speedometer was in the wrong orientation, it also wouldn't fit my handlebars since the bracket was way too short.