There is no absolute way to tell, no spell that says "he's level 10/10 HD." You have to go with context clues and observation instead. That leads us to a two-part answer.
DM Description and Observation
Observe more closely and the DM should be more forthcoming with details. In many cases, higher level NPCs/monsters look different - think World of Warcraft, you can tell a high level person because of their crazy pimp looking gear and purple energy coming off them and stuff. Maybe he has ioun stones whizzing about his head, etc. Judicious use of detect magic, detect evil, etc. can tell you strength of auras. A DM should also think through setting up context clues per How can DMs effectively telegraph specific dangers in D&D? - like maybe someone powerful comes to mess with him and gets disintegrated while he's chatting amiably with the PCs.
Many high level characters are obvious - a gnome in a robe of the archmagi riding a dinosaur with all kinds of magical protection glimmering around him is obviously bad news. If all your gear is platinum and adamantite it means you're bad ass enough to keep a hold of it from random bandits and/or adventurers. Your DM should be conveying this detail, as long as you pause to take a look.
In some cases (monsters, undead) skill use may let you get a better read on what it is you're facing. In 3.X this was sadly routine (I will roll and you will tell me exactly what this is), in 5e this isn't as guaranteed a method of knowing exactly what's up and there's more DM discretion, but at least asking for a roll and getting hints might help.
It definitely sounds like your DM needs to be thinking through this more and giving more context. "Hey this dead guy looks a lot like that statue of Archmage Xulibraz back at the Acadamae..."
Play Smart
In some cases, a high level person isn't going to look/detect different from a low level person. This should be more rare unless your DM is a dink, though there are exceptions. A high level monk in rags looks like anyone else and a king might have super pimp gear despite being level 1 just because of daddy's money. Now, if you see the monk fight it should be like watching Jet Li and you should get the clear impression he could snap your neck and isn't some random yokel. But this is where the onus shifts to you. If you decide to just roll up on someone without knowing much about them, there's a good chance you're going to get owned one day. You have to be smart.
Observe folks. Ideally, use time prior to the actual encounter. If you know about them way ahead of time then there's divination spells or sage research or "asking around on the street." See if you can observe them fight someone or cast a spell or use a skill to where you would see "holy crap they are about 500% better at that than I am." Have a backup plan. If you just kick down doors and attack people, 1 in 10 times you're going to bite off more than you can chew and you'll need a fallback. That floating thing could be a beholder or a gas spore. That undead could be a zombie or a lich. Knowing that there is that range of foes, it's up to you to decide whether you want to be all reckless and maybe die one day or whether you want to be super cautious with everything or where you want to fall in between - just like real life.
Conclusion
You have just learned a valuable lesson, and learned it without dying! Congratulations. The world is dangerous and it's not always neatly labeled or level appropriate. Let this inspire you to think about how to suss out your foes both from afar and when in direct contact with them. It'll keep you alive more than a fistful of plusses.
Here's how I did it. Back in the day (AD&D 2e, but I don't see how it being Pathfinder is particularly relevant to an answer) I had a casual group that usually played kick-down-the-door. Well, it was the late 1990s and we had gotten wider RPG exposure and decided as a group that we wanted to play a serious, immersive, simulationist game. So I started a new campaign (based on the Night Below boxed set).
The PCs showed up in a small town and a magician's apprentice went missing; the party gnome had befriended her so they decided to search for her. They're in the inn that night, a couple travelers come in. One has a facial tic. Since from earlier, whatever the nice way of saying "worse" is, D&D campaigns they were conditioned to assume anyone with any distinguishing feature was important, the party elf and dwarf went over to interrogate him. In reality he was just a tired traveling merchant, and all they got for their trouble was "Slag off." They kept at him and he indicated that the shortsword he was wearing wasn't just for show and they should leave him alone. Both the elf and dwarf immediately pulled out their weapons. The man, terrified, ran out of the inn. They pursued him into a field and the dwarf shot him with a crossbow. He blubbered and tried to get away from them while the local carpenter slash constable showed up and suggested everyone come to his office (carpenter shop) to figure out what was going on.
The elf and dwarf's story as recited to the constable was "We thought he might know something and he wouldn't answer us so we chased him into the field and shot him." This lined up remarkably well with the man's story. "So... That's the explanation you're going with?" asked the constable. The party cleric showed up and healed the guy, so he said "You know, the town mayor is a hard man... I will just assess you a 20gp fine, or if you don't have that you can work in my shop a few days to work it off."
The dwarf took this deal, but the elf insisted he was "just trying to rip them off" and "wasn't listening to their side of the story." "I'm listening, but your side of it, if I understand this right, is you chased this guy into the night and shot him because you were playing vigilante interrogator?" So he got held over for trial the next day.
The mayor came out, and got the same story recited to him. "Three months hard labor in the mines. Next!" "So, do you want to roll a new character, or play a NPC for a couple months of game time, or what?"
Guess who has two thumbs and didn't have a problem with players not thinking about consequences for the rest of his (5 year) campaign? This guy!
My advice is - don't screw around. Once everyone's agreed "oh yeah realistic world that's the concept we're on board with" then you just do it. You'll note I gave them an out, but the one PC that decided to be hard-headed about it got the consequences in spades. Eh, he was first level and didn't have that much backstory, and then I got to bring him in as a bad guy later on. I deliberately seeded this scene to see if this topic needed addressing, and it did. Notice I didn't use the more cliche "overwhelming force" variant where the merchant was a level 10 fighter because the point I needed to make was not that "there's always a bigger guy," but that "you are a part of a larger society that cares about how things go down." Craft a scene to reinforce whatever specific lesson you need to make and then see if they learn or need some learnin' applied to them more vigorously.
Running a game is like raising a kid or training a dog. Do it the first time, be consistent, you'll have a lot less problems than if you waffle or delay addressing problem behavior directly. They are fantasy characters - it's OK to kill, maim, send to jail, take their stuff - whatever you need to do in order to get the boundaries across.
Best Answer
There are a few resources you can reference for examples of how to handle such specific injuries.
Scars and Wounds from Skull and Shackles
The Skull & Shackles Player's Guide includes a sidebar on permanent scars and wounds as an optional rule to support representing the harsh piratical lifestyle; it is reproduced alongside the Injury and Death section on d20pfsrd.com. Specifically, a possible result is:
The leg doesn't need to be actually lost; the result could still be appropriate even if it's just very badly mangled.
Called Shots from Ultimate Combat
Ultimate Combat includes optional rules for implementing called shots to represent deliberately targeting an opponent's limbs and other features, and the result of a "debilitating blow" can permanently wound a creature. For instance, a called shot to the leg can have the following results:
Most of the consequences described are temporary but you could make them permanent if you needed to represent the damage long term.
Loss of Limbs and Prosthetics from 4 Winds Fantasy's Strategists and Tacticians (3rd party)
If you're happy to look at 3rd party products, 4 Winds Fantasy produced some rather more developed rules for losing limbs and prosthetics that have much more serious consequences than the other examples:
These penalties are very severe and would give the character a pretty hard time in combat, so you'd probably want to mitigate them somewhat by giving the character a suitable prosthetic. You could also use the somewhat less harsh penalties for simply losing a foot, instead.