Peter denied Christ while Christ was still in the flesh. It doesn’t say anything about having to be ‘worthy’ to keep the Holy Spirit, nor does any other verse in the Bible teach that.
The Savior said that blasphemy against the Holy Ghost shall not be forgiven unto men. Matt:12:31-32
Can a man have the Holy Ghost and lose it? You bet. Anything given to man from God can be taken away through transgression.