Length is the obvious signal, but it is not the only one. A few details push any outfit up or down the formality scale.
Fabric does a lot of the work. Satin, crepe, chiffon, beading and sequins read as evening wear. Cotton, jersey and casual prints read as daytime, even on a long dress. Structure matters too. A fitted bodice and a defined waist look more formal than a loose, unstructured shape.
For suits, color and fit carry most of it. Black, navy and charcoal read as formal. A suit that fits well through the shoulders and a jacket that stays on in photos read as more formal than a loose suit or no jacket at all. A bow tie leans formal. A long tie in a dark color sits comfortably between formal and semi-formal.
Accessories finish the job. Dress shoes rather than sneakers, a small clutch rather than a backpack, and jewelry chosen for the outfit all lift the overall look. None of these are rules. They are just the signals people read when they decide whether an outfit fits the night.