That depends what you mean. Psychological pain isn’t really “pain” in the same context, it’s part of more complex thoughts within the mind.
Where do the brin signal come from? something outside body or is it only the physical pain they feel? if yes, how can they feel a non physical leg?
Brain signals are electrical impulses generated by the brain. They can be
triggered by both nerve impulses and by internal feedback within the brain. As a simpler example than pain, if you want to count the number of apples you’re currently holding, the raw data will come via impulses from your eyes and hands. If you want to count the number of apples you’ve eaten this week, the raw data will come from your memories inside your brain. The process of actually counting and coming up with an answer will happen in a similar way though.
Phantom pain can be something of a mystery but it could happen due to an error either in the remaining nervous system, sending false signals as if they were coming from the missing limb or errors within the brain, triggering signals even when no valid signal comes from the nerves. In more general terms, we’ll all have experienced examples of us imagining physical sensations that didn’t actually happen or things that are misinterpreted by our brain. None of these systems are flawless.