A play from 1861 might be a partial answer.
The Tragedy of Man has several scenes which can be considered science-fiction: set in the future, it describes a different human society which uses futuristic technology, and the relation between technology and society forms an important plot point in the story.
The story goes through many eras of human history, from biblical times, through classical antiquity, middle ages and the author's present, but the last scenes are set in the future. Scene 12 presents a highly technocratic society, where poetry and emotions are banned, every member has one and only one job through their entire life, and people are referred to only by numbers. Any form of emotional relationship is banned, babies are separated from their mothers and raised in a communal nursery. That society is based on extreme utilitarianism: nothing is tolerated which is not immediately practically useful. Poetry is banned, flowers are extinct, and so are almost all species of animals and plants. The only remaining land animals are heavily genetically engineered:
What lives is what is useful or what science
Has found no adequate substitute for yet
Like pigs and sheep, but not in the poor state
The nature so ineptly left them in.
One’s living fat, the other meat and wool,
They serve our needs, exactly like these test-tubes.
Like many modern dystopian works, on first glance it seems like a utopia, and the protagonist at first thinks it is one, and only later does the inhumanities come to surface.
Not only is this society dystopian, it is so by necessity, because the world itself became dystopian due to severe resource exhaustion by preceding civilizations.
Later, it turns out,
even these drastic measures were unable to save human civilization. A scene set a few thousand years later shows a snowball Earth, with barely survivable arctic climate around the Equator (and completely dead everywhere else) where the last few human survivors eke out a miserable living, degraded back to the stone age, heading inevitably towards complete extinction.