Multiattack Defense only helps against legendary actions with multiple attacks
The ranger's Hunter archetype Multiattack Defense feature states:
When a creature hits you with an attack, you gain a +4 bonus to AC against all subsequent attacks made by that creature for the rest of the turn.
The text for legendary actions states
A legendary creature can take a certain number of
special actions--called legendary actions--outside its
turn. Only one legendary action option can be used at
a time and only at the end of another creature's turn.
If the dragon hit you on its turn triggering Multiattack Defense, the first time it will be able to attack you again with a legendary action will be outside its turn, that is, not during the turn where it hit you. The Multiattack Defense it triggered during its turn does not apply any more.
The end of a creature's turn is part of that creature's turn. The legendary attack does not happen on the dragon's turn, but it happens on the character's turn.
There are actually a few select monsters that have multiple attack options with their legendary action, for example Eberron's Sul Katesh can make multiple attacks with her arcane blast, Jarlaxle Baenre can make multiple attacks with his daggers, and a Giff Warlord from Boo's Astral Menagerie can make two morningstar attacks.
If one of them attacked you at the end of your or another character's turn, and hit you with the first attack, this would trigger Multiattack Defense for the subsequent attacks.
For the dragon however, which only can make a single attack with its legendary actions, it will not do you any good.
P.S. A possible exception is if the dragon hit you with an attack on a turn that is not its own, for example it could have had a readied action to bite anybody who comes into reach, or it could bite you as you move out of its reach as an opportunity attack. In those cases, it could successfully bite you, and then at the end of that same turn, as it is not its turn, hit you with a legendary attack. Since that would still be the same turn, your Multiattack Defense would kick in here. (Thanks to @MJD to point out the corner case).