When Spotify Technology SA went public in April, Goldman Sachs Group Inc. was sitting on a stake in the music-streaming startup worth more than $350 million, a sevenfold return on a 2012 investment.

Those gains weren’t the handiwork of any of the hundreds of Goldman professionals whose day jobs are to invest in companies. They came instead from the firm’s bankers, who have been quietly moonlighting as venture capitalists.

These corporate consiglieres, who advise on mergers and underwrite securities, oversee a venture-capital portfolio worth several hundred million dollars, according to people familiar with the matter.

Plenty of big banks invest in promising startups, but they typically do so through their strategy groups or asset-management arms. Goldman has those, too, but they are distinct from the portfolio maintained by its investment bankers, who are investing on the bank’s behalf.

The bankers were early backers of now-household names including Uber Technologies Inc., online storage vault Dropbox Inc. and payments company Square Inc. Recent investments include Ripple Foods, which makes milk from peas, and Marqeta Inc., a credit-card startup, the people said.