You may be thinking of one of the poems of Christian Morgenstern? He used many tricks of formatting for jokes, famous example that fits with yours is The Funnels
https://www.babelmatrix.org/works/de/Morgenstern%2C_Christia...