The long and short answer, most of the time, is no. Professional producers in any sector of media (film, TV, comics, radio, audio, novels, games etc.) want to see your vision, your voice, what you bring to a project. They want you. Fanfiction won't do you a lot of favours and is almost never advised as a proper writing sample: it's legally in a grey area, you're working with characters you don't have a legal license to use and it doesn't do enough to sell you as a writer in your own right. Plus, most of your favourite properties already have the agented writers banging on their doors: you will simply raise the odds against yourself.
There is ONE major exception, which I will come onto in a few paragraphs.
Is that to say fanfics are worthless? Not necessarily: Anywhere you can train up and build up experience is always handy when it comes to writing. Refining your craft is what counts, not where you do it. You don't have to worry about budget concerns or exec notes, so only your imagination is your limit. However, a balance with original work is vital if you actually want to make the jump from amateur to pro.
I do not believe the practice of working with other properties, unlicensed, is useless either in craft: not just because of the upcoming 'exception', but because adaptation is one f the bread-and-butter gigs, whatever field you get into. Working with others' materials is something you will come across, and getting some practice in without producers breathing down your neck, capturing another style and voice, can be handy.
Here's a five point plan I've cooked up if that's your game:
1) What is your goal? Do you want to be a working writer, or just writing one property? While that may sound arbitrary, it's important to consider because they each need different things: if all you want is just to write Who stories and nothing else, you're better off sticking to fanfiction sites as the grind exceeds what you really need. It may not be canon, but if you enjoy writing in that universe, that shouldn't matter.
If, however, x or y franchise is just 'a goal'
and you want to have a full career, beyond that, then that's a whole other kaboodle. Do you have favourite genres? What style do you like to write?
What subjects or themes interest you? Do you have weird or funny
memories, friends or relatives that could provide a great basis for a
story? Write those and give yourself plenty of time: no one will ever thank you for giving them rushed work.
2) Being realistic. Getting to any dream is slow, and this doubly true
for writing. The addage is 'it takes 10 years to break in', which is a
good metric (though many have done so in half the time) to avoid
disappointment and losing your passion. Treat nothing like a guarantee
and be ready for a lot of unreplied emails and non-answers as you build a
body of work. It's just the reality of the entertainment business.
3) Learn learn and learn: invest in your education. Read
scripts and prose,
learn drama theory, take classes/workshops and join writing groups.
Sharpen those skills and be open-minded. Always refine your work and
approach, which thanks to the internet, has never been easier to do.
Youtube is awash with free writing tutorials, lecture and seminars, if
you're really tight on cash. It's also great as it's flexible to suit
your current lifestyle. Learn what pitches, loglines, treatments and
beat sheets are - they are a necessity in professional media production.