The largest record labels are closing in on a deal for a stake in buzzy digital-music service SoundCloud Ltd., in exchange for an agreement not to sue the startup for copyright violations, according to people with knowledge of the plans.