For example, if Donald Trump lost a primary in 2024, he could still run for president. If so, he might theoretically want to appeal to Republican voters by claiming to be "the real republican candidate" and accusing the official candidate of being a "RINO." What limitations would he face in executing such a campaign? Can a candidate run as a party X candidate without an official endorsement from the party? Are there any historical examples of this sort of thing?
Can a candidate run as a party X candidate without an official endorsement from the party?
No, because it is the party rather than the candidate that gives official endorsement. A losing primary candidate from party X for president could however theoretically claim to be an independent or win in some other party's primary (or gain endorsement by some other party in some other way) in all but two states, South Dakota and Texas.
All but three states have some kind of sore loser law that precludes a party switch for some elections between losing a primary and the general election. However, all but South Dakota and Texas have clarified their sore loser laws to state that they do not apply to presidential elections.
It is the national party rather than the state that decides who gets to carry that party's label during a presidential election. I do not know what would happen if someone ran for president in party X's primary in South Dakota or Texas, switched to party Y, and then won enough primaries to win that party's convention.