It would be rare, but yes, you can use the second option. You can ask:
"Why are all these flags having been being put up all over the city?
To think about this sentence, first simplify it:
"Why are all these flags all over the city?"
The verb is *are*.
Example Answer: I don't know; I guess someone put them there.
You can use "having been being put up" as a gerund that functions as an adjective to describe "flags." Thus:
Why are all these flags [having been being put up] all over the city?
Same Answer: I don't know; I guess someone put them there.
or, add two words to change the meaning a little:
Why are all these flags [having been being put up all over the city] still there?
Answer: I don't know. I guess no one has taken them down yet.
Of course, you would not write the sentences with the brackets [], but I put them there so it is easier to see the gerund, which is 'having been being put up'.
But you would only use such complicated conjugations rarely, and you probably don't need to worry about it. And you can probably forget you ever read this answer... Having been being invited to read this answer, you can now forget it.