Some years ago there was a homeless guy who used to hang around our church. He was very obviously not in his right mind and sometimes his behavior was bizarre. As I recall, people helped him out as they could. One day we found out that the police had arrested him for some reason and that he had hanged himself in his prison cell. My priest gave him a funeral.
I have no idea what the official rules are with regard to suicide. The impression I have is that if there is evidence the person was mentally unstable when he committed suicide, he will have a funeral.