The legal answer is that they could if they got wind of it. In reality -- no, of course they won't. But a major online realtor selling copies of fanfic online is a much bigger potential threat to their trademarks and a bigger violation of their copyright, so it would be more rational to go after that than what you just described.
Exactly. But "selling" is one thing, "free download" is another. I do think that fanfic publishers need to be sensible - and refrain from using the word "Star Trek" on the cover of their eBooks.
"Going after" the retailers is the wrong approach. They're not actively causing the problem; they do have rules against selling copyright-infringing material, and they do enforce them when they discover it. At worst, they're just not enforcing them enough. So it would be stupid for the studio to treat B&N or Amazon as the enemy, to attack them and alienate them. What they should do is work with the retailers to improve their enforcement, treat them as partners in resolving their mutual problem. Technically, all fanfiction is illegal copyright infringement whether you profit from it or not. But typically, studios only bother to enforce that law when the material is sold for profit, because it's too much trouble to go after all the fanfiction. And in the case of Star Trek, Gene Roddenberry specifically asked Paramount to go easy on the nonprofit fanfiction because it helped build the fanbase. This is how fan-film franchises like Phase II are able to thrive.
From a traditional CBS/Paramount tolerance of fanfic, there would seem to be. Fans used to charge people for printing and postage of fanfic. They weren't supposed to make a profit. I have had my fiction ST fanzines sold in specialist bookshops, and I've bought fanzines from more mainstream shops. The zines did not use the "Star Trek" name or logo and I didn't make a profit, although the shops often added an amount to my RRP. We also regularly supplied club newsletters to local bookshops. Fully aware of that. And "cease and desist" letters would be sent to fanzine publishers who deliberately made their products look too much like licensed material. Exactly. Each ST movie's official media release package has always included a paragraph attempting to estimate the then-current output of fan-generated, unlicensed materials. After the first two "Star Wars" movies, George Lucas rampaged over many media fanfic zines which had broadened their activities to include "Star Wars" material to their stable.