Assuming this is a step-ladder, This is a physics question and it's about centre of gravity. Stability is increased with a low centre of gravity and decreased as the COG is raised. When you stand on the top of the ladder, you are above the natural centre of gravity of the ladder and any movement you make increases instability. So it is undoubtedly dangerous.
If it is a ladder leaning against a wall, then it is about friction and force-vectors. Below the top rung, there is a downward force into the ground and a lateral force into the wall. When you stand on the top rung, there is no significant force into the wall. Your position up the ladder acts as a lever against the friction at the bottom; and if the friction at the base is at risk of giving away. The ladder will slide down the wall. This depends on the angle of the ladder to the wall so it's important to pick the best angle and don't use the top rung. Ideally, anchor the feet to the ground/tie the ladder to the wall.