Ensign appears in naval novels, history documentaries and occasionally in crossword clues, wearing three related meanings. Once you see how the senses grew from one another, the word stops being trivia and starts being readable.
The oldest sense: a flag
An ensign is a flag, especially one that shows a ship's or nation's identity at sea.
Merriam-Webster leads with the flag sense. The Red Ensign and White Ensign are the famous Commonwealth examples, flown to declare a vessel's nationality. On US Navy ships, the national flag flown at the stern carries this name while the jack flies at the bow.
From carrying the flag to being an officer

The banner carrier's title became a rank, so ensign now names the most junior commissioned officer in some navies.
The US Naval History and Heritage Command traces exactly this drift: the warrior who carried his lord's banner was called by the banner's name, and the title hardened into a rank, equivalent to a second lieutenant in other services. The same drift produced other military job titles that stopped describing the job.
The badge sense and everyday reading
Ensign can also mean a badge or emblem of office, which is the sense readers meet in older literature.
Context almost always announces which sense applies: a flag flies, an officer is commissioned as one, and a badge is worn or borne. In modern English outside naval contexts, expect the flag sense in history writing and the rank sense in fiction set aboard ships.
FAQ
Is ensign still used for army ranks?
Historically yes in some forces, but modern usage mostly meets it as the naval rank.
How do I use ensign in a sentence?
Typically as the ship flew the Red Ensign at her stern or he was commissioned as an ensign.
Is insignia related?
Yes; both trace back to the same Latin root insignia, an emblem or badge.