Another iconic example from The Original Series was the episode "The Devil in The Dark", where Federation miners were being attacked by a monster and they asked the Enterprise to help them find the creature and kill it. Despite the alien's VERY non-human appearance, it turns out that A)it is sentient, B) it only started attacking the miners when they carelessly destroyed several of its eggs, C) it is actually quite friendly and willing to help if the miners would stop doing that. To their credit the human miners are horrified to discover they've been killing alien babies and are willing to forgive the monster for killing several of their own.
In "The Measure Of A Man," he is the subject of a hearing by the Judge Advocate General of Starfleet to determine his legal status: is he property or a person? The judge mentioned that they were "dancing around the basic issue -does Data have a soul?", which she concluded could not be proven or disproven, just as it could not be proven or disproven for humans and other organic sentients.
Later episodes on the topic featured Data defending the right of other artificial sentients to live, and the question of Data's "daughter" Lal and his parental rights concerning her.
The episode "The Quality of Life" dealt with it as well. A scientist invented "Exocomps", droid-like multipurpose tools with sophisticated AI. Occasionally an Exocomp would start to exhibit odd behavior, such as disobeying commands that would put it in danger. This leads Data to suggest that the Exocomps are becoming self-aware. Their inventor disagrees and wants to erase their memory and start over. The episode treats the question seriously and concluded that there was no easy answer.
In "Inheritance", Data meets his mother, Juliana Tainer (formerly Juliana Soong). It later turns out that she is an android too, created by his father to appear totally human and with the copied memories and personality of the original Juliana (who died after slipping into a coma), but she is unaware of this fact. When Data accesses the holographic message his father left in Juliana's positronic brain and confronts him about not telling her what she really is, Dr. Soong makes his feelings on the matter clear:
Data: Then... you do not believe she should know the truth?.
Dr Soong: Truth... the truth is, in every way that matters, she is Juliana Soong.
The episode "Evolution" dealt with a colony of nanomachines that evolved greatly after they escaped Wesley Crusher's containment and began messing with the Enterprise. A scientist that was on board the Enterprise continuously demanded their destruction, mostly because they were screwing around with his experiment and he was on a strict time table. Ultimately, the nanomachines and the scientist comes to an understanding and the nanites are dropped off on an uninhabited world to evolve on their own.
The treatment of duplicates in Trek is even more schizophrenic. Just to examine two episodes featuring Riker:
In "Up the Long Ladder", the crew encounters the Mariposans, a planet whose hat is reproduction through cloning, but the replicative fading (a real phenomenon) is starting to catch up to them. They rip off DNA from Riker and Pulaski. When this is discovered, Riker and Pulaski (a doctor!) find the lab and blithely massacre the duplicates. Riker states that the clones' existence "diminishes" him.
In "Second Chances", the crew discovers another Riker (who comes to use "Thomas", his middle name), created unknowingly by a transporter accident early in Will Riker's career. Even though they clash, Tom's personhood is never questioned (Will treats him as the twin brother he never knew and saves him!), and he eventually comes to be treated as if he were a newly awake coma patient, leaving to build a new life.
Star Trek: Voyager explored the rights of the holographic doctor, including his right to have a say in his treatment.
In "Latent Image", rather than delete months of his memory (and personality), Janeway eventually allowed him to work through psychological problems that could have kept him out of Sickbay for weeks or even months — despite the risk this might pose to the crew. Janeway had initially decided to just reboot the Doc, but changed her mind upon talking to Seven of Nine. When Janeway pointed out that the Doc was more like a replicator than a human, Seven pointed out that she, too, being Borg, was composed of parts not unlike the replicator, and wondered whether Janeway would eventually override her free will as well.
In "Author, Author", the Doctor had written a novel and submitted a draft, pre-editing, that the publisher thought was delightfully salacious in the way it seemed to impugn the Voyager crew, and promptly started distributing. The Doctor sued to have it stopped; the publisher argued he couldn't sue because he wasn't a person. One might expect someone to look through Starfleet's records and discover that an artificial being that has intelligence that can improve itself, have sex, and express itself artistically is a person, as Data was found to be so in the second season of The Next Generation. This was done again with polymorphic tools called Exocomps that were proven to have gained low-level intelligence and were excellent problem-solvers. Admittedly, ruling that the Doctor was a person would open the door to ruling the same for Mark I EMHs all over the Federation, who had by then been consigned to slavery and manual labor (that is to say, one of the things Picard was trying to prevent); meanwhile, there was only one Data. It gets even less justifiable when you consider that the Doctor is essentially a Projected Android. Ultimately the judge ruled the Doctor was an author, which gave him rights to his work, but left the issue of his personhood for some later court to decide.
Fair Haven and Spirit Folk establish that all holographic characters are sentient people and everyone knows this, they just usually have a hard-coded Weirdness Censor to keep them from realizing the nature of their existence. It makes everybody treating them like video game characters kind of horrifying in hindsight.
The main villains are the Jem'hadar, genetically-engineered super-soldiers. They're bred to be obedient and violent, and there are an awful lot of them. Their main purpose is to get killed in hand-to-hand battles. Every once in a while we meet an individual Jem'hadar who acts almost like an ordinary person, and our heroes pause to consider their dignity. Of course, since the majority of the Jem'hadar encountered by Our Heroes are enemy combatants, the question is largely academic.
Their creators are, interestingly, large proponents of "What Measure Is A Non-Changeling." Basically they're a race of sapient goop who, due to some bad experiences in the past, have come to the logical conclusion that the solid races all need to be controlled and will treat all solids as essentially cattle that needs to be corralled.... which runs them not only against the Federation, but against Odo, the primary Changeling character on the show.
One episode had a direct Take That! to "Up the Long Ladder", where Odo points out while arresting a criminal who had faked his own death that killing your own clone is still murder.
There's an interesting mission in Star Trek Online. It deals with a Ferengi wanting a hologram program to complete his collection. He asks you to persuade another person to give him a copy. However, it's not a humanoid being, but rather a photonic being who holds the program. The rest of the mission is a small part about seeing photonic lifeforms as sentient. So in the future of the Prime timeline, photonic beings do gain some rights. Come to think of it, you can get a photonic bridge officer as well. One of the loading screens mentions that the Doctor ended up driving the issue to the Federation Supreme Court, which did indeed decide that he was a person.
In Spock's World by Diane Duane, Kirk is chatting with a friendly AI named Moira, who lampshades this trope. Kirk doesn't seem to mind having a sentient computer onboard, but he knows Starfleet might pull such a computer's plugs, so he orders Moira to keep it secret.
""Your intelligence is just electrons," she said, "the same as mine. You're just electrons... the same as me. You always seemed too intelligent to be a protein chauvinist, Captain."