Max heart rate often isn't that interesting, because you can't sustain it for very long.
The lactate threshold, more or less the sustainable max, is more interesting.
But if you really want to hit your max heart rate, a ramp test will generally do it.
The Bruce protocol is one standard for treadmills:
The Bruce protocol consists of a maximum of 10 three minute stages. Participant starts walking on the treadmill at 1.7 mph and an incline of 10 percent. Every stage the grade is increased by 2 percent. The speed is increased every stage starting at 1.7mph, and then to 2.5 mph, 3.4 mph, 4.2 mph, 5.0 mph, 5.5 mph, 6.0 mph, 6.5 mph, 7.0 mph and the tenth and final stage is 7.5 mph with an incline of 28 percent. This is the highest stage, but since it is a maximal test and the participant persists until they are too tired to continue, it will likely end long before it reaches that stage.
Ramp tests are generally short, increasingly hard, and end when you quit.
If you are doing one on a bike, its safer to do it on an indoor trainer than on a road.