Can someone with a mental illness own a pistol?

Generally no.
Each state has its own laws regarding gun ownership, and mental illness is usually a disqualifier in all of them.

The term "mental illness" can refer to many different problems, some serious, others not. If ever there is a borderline case, I think the authority would err on the side of caution and not allow such ownership.