You're getting there.....
You didn't need to add an extra 'analogWrite()', directly writing the duration to the PWM pin. It makes the following conditional useless, as well as writing an out-of-range value to the PWM pin.
Think about exactly what's happening -
1. You do a ping. (OK so far)
2. You measure the pulse. (Still OK)
3. You convert it to inches and cm. (OK, but one or the other would be better)
4. You spend 10 to 20 mS doing serial prints. (Serial prints are OK, but they do take 10-20mS at 9600 baud, so not now.)
5. You write the duration in microseconds directly to the PWM, (LED) pin. (This is bad, especially since that value is likely to be in the thousands, whereas a PWM pin expects a value between 0 and 255. A random value is being written when you don't want to write anything at all to the PWM pin yet.)
6. Now you wait for 100mS before determining if the target is within range. (If the target is moving, during this total period of 110 to 120mS it will have moved closer or further away, so the LED brightness won't end up corresponding exactly to the distance. Since the most important things are the operation of the ping sensor and the LED, give those operations priority for best results, and do them one immediately after the other.)
7. Finally, you now do the conditional which in turn determines whether or not you will even set a PWM value, and what that value will be (after mapping to 0-255). (Except that you've already written a wrong value to the PWM (LED) pin 100mS ago, so you're seeing a blend of the right value and the wrong value in the LED brightness, flickering at a bit under 10Hz.)
While it doesn't hurt, it's probably a better idea to use a separate variable for the LED brightness, too, rather than 'duration'. If nothing else, then it can be given a more meaningful name, like "brightness". 
Generally, when programming, it's not a good idea to use 'delay()', either. It's far better to use 'millis()'-based timing. There's a good example of that basic method in the "Blink" example. For now, though, I'll leave it in, but move it to a more approriate place.
Another point - do you really need the measurement in both inches and centimeters? It's better to just work with one unit - whatever you usually use in your country. (Not a necessity, just a suggestion.
)
Anyway, having said all of that, (just to help you understand - I'm not having a shot at you), here's a re-arranged and repaired version of the code. It's 4am and I'm tired but couldn't sleep, so hopefully I got it right.)
Oh, I just noticed. You declared these twice, both globally at the top and locally in the 'loop()' function.:-
long duration, inches, cm;
Once, in 'loop()', is enough, and I changed 'cm' and 'inches' to int, since they won't be big enough to need a long.
Anyway, see how this goes:-
const byte led = 9;
const byte trig = 10;
const byte echo = 11;
void setup()
{
pinMode(trig, OUTPUT);
pinMode(echo, INPUT);
pinMode(led, OUTPUT);
Serial.begin(9600);
}
void loop()
{
digitalWrite(trig, LOW);
delayMicroseconds(2);
digitalWrite(trig, HIGH); // Generate a 'ping'.
delayMicroseconds(10); // " " "
digitalWrite(trig, LOW); // " " "
long duration = pulseIn(echo, HIGH); // Measure the echo time.
// Convert the time into a distance:-
int inches = microsecondsToInches(duration);
int cm = microsecondsToCentimeters(duration);
if (cm >= 10 && cm <= 100) // Check if within range. (About 4 inches to 3 feet)
{
byte brightness = (byte)map(cm, 10, 100, 255, 0); // Convert 10-100 to 255-0.
analogWrite(led, brightness); // Generate PWM.
}
// Print the results:-
Serial.print(inches);
Serial.print("in, ");
Serial.print(cm);
Serial.print("cm");
Serial.println();
delay(100); // Delay between readings.
}
int microsecondsToInches(long microseconds)
{
return (int)microseconds / 74 / 2;
}
int microsecondsToCentimeters(long microseconds)
{
return (int)microseconds / 29 / 2;
}
Now back to bed for me. 