The slow blade penetrates the shield.
This quote comes from Frank Herber's Dune, and it is probably the archetypal example of what you are looking for. In this series, Herbert specifically wanted a world where melee combat mattered, but there was technological interstellar travel. To accomplish this, he invented the shields. The personal shields were normally in a "down" state, which let air enter the shield's volume. However, anything fast moving immediately raised the shield, preventing anything from entering (you could get light headed from low oxygen levels inside your shield in a protracted fight).
The result was a melee combat style which involved slow movements of a knife to get inside the shield, followed by a quick killing blow.
Herbert wanted the combat to be personal, which points to a second major reason one might choose melee weapons.
"All can be redeemed." - Praetor Fenrix VII
Melee weapons may be preferred in a highly advanced society which has grown to deeply respect the value of life. Killing is a big deal, and it may be an even bigger deal for some advanced species who have gotten to see just how much can be lost. But even the most advanced species can't help but spill blood at some point. For this, such a society would prefer the opportunity to redeem the opponent, all the way up to the last moment.
With a ranged weapon, your ability to craft such an alternative ending is limited. You pull the trigger, a hole appears where their brain matter was. One, two, the end. With a melee weapon, you spend time attached to your opponent, quite physically. There is a period of time where you can seek to influence them. This can even occur after the knife has gotten under their skin, but before it hits something truly fatal.
A killing with a ranged weapon in that world would be barbarous. But with a knife, and great skill, a holy warrior with an official charge from their cardinals could go back and try to redeem Hitler himself. Perhaps a knife wrapped part way around his carotid artery, lifting it out from his skin without fully severing it, might be just the leverage needed to lead him to become born again.
And if not, the knife works. As it always has.