Question: > 
> Which one is formal or widely used in writing? '**aged 11-17**' or '**aged
>  11 to 17 years**' or '**aged 11 to 17**'
> 
> 
> 

The complete phrase is 'students aged 11 to 17'

Answer: 
You can write any of them. It is personal preference as to whichever one you choose as they are all perfectly valid. All of them are widely used, writing 11-17 is just a shorthand way of saying 11 to 17 (years). 

You only need to say "years" if you want to clarify that it is not 11-17 minutes or 11-17 hours. Otherwise people will tend to assume you mean 11-17 *years* based on the context.
As I mentioned in my comment, all three are used extensively. But, since you've used "Aged", you need not add a "years" at the end of the sentence. It seems redundant, which can be avoided. Then the question is "To use a hyphen or a "to". To avoid any sort of foolish interpretation, and to make it fool-proof, I suggest you use "to". I had this friend who read out a sentence which was written as : 

> 
> "Trainee Package (1 Month) : 12,000 - 15,000"
> 
> 
> 

and that brilliantly stupid girl asked me why they were subtracting a greater amount from a smaller amount and wanted to know whether we had to pay them an amount of 3,000 back to the company. Yes, there are people like that. So make it as clear as it can be.