Sturgeon wrote three episodes for the TV show Star Trek: "Amok Time," "Shore Leave," and "The Joy Machine." These episodes were good, bad, and unused, respectively.
"Amok Time" is one of the most famous episodes of Star Trek. It is mating time for Spock, and he is driven to return to the planet Vulcan by his biological urges. There, he eventually battles to win the right to mate with Vulcan T'Pring -- but she chooses Capt. Kirk to be her champion. Thus we have Kirk battling Spock to the death, and Spock's lost almost all self control due to his mating urges. The ending to this show is clever, unlike some ST episodes. This show first featured the Vulcan greeting "Live Long and Prosper." Also, it has one scene where Spock actually smiles, one of the few episodes where his human half shows through. Many people consider this episode their favorite.
I haven't seen "Shore Leave" yet. This episode features the Star Trek characters interacting with various other fictional characters, such as the White Rabbit from Alice in Wonderland.
"The Joy Machine" was never used as an episode. James Gunn, a friend of Sturgeon's and an active sf writer, has adapted the script into book form (Star Trek #80, the original series, Pocket Books, 1996). The book has scenes which would have been far too complicated for the special effects ST had, and it is not suprising it was unused for that reason.
In "The Joy Machine," the Enterprise crew is sent to investigate the planet Timshel. Formerly a leisure planet, now the planet has cut off all contact with the rest of the universe. Previous Federation agents sent to investigate have disappeared. Also missing is one of Kirk's former loves. Kirk discovers that the inhabitants of the planet are controlled by a machine (a computer) which sends jolts of pleasure directly to the brain in exchange for having completed menial tasks. The population has been reduced to slaves for this machine, and they are all quite happy about it. This book features a debate between Kirk and the Joy Machine, as well as a terse debate between the Joy Machine computer and the Enterprise computer which occurs throughout the book. This book is fairly enjoyable, if you like ST books.
This book also features an afterward by James Gunn discussing his relationship with Sturgeon, and how he came to write this book from Sturgeon's unused screenplay. (Note that Gunn also wrote a book earlier called "The Joy Makers," which is unrelated.)
Other prominent sf authors who wrote episodes of Star Trek included Robert Bloch, Frederic Brown, Harlan Ellison, and Normal Spinrad.