Sure, thats what they did with the JWST. But that ist complex and expensive. A custom Starship could be the cheapest way to get telescopes up to 9m mirror size into space as you can assemble everything on the ground and you don't need a separate housing.