SAN FRANCISCO—College football players, rock stars and the Three Stooges have all enjoyed court protection for their publicity rights in recent years.

On Tuesday, a California appellate court declined to extend that principle to one of the world’s most famous cocaine dealers, ruling instead that a rapper had a First Amendment right to borrow his name and sing about his criminal exploits as if they were his own.