I have some idea of how well I'm doing with my research in PhD, but maybe it differs from what my advisor thinks. Is it okay to ask (e.g. at the end of a meeting) how well I'm doing with my research? Can I say "Oh, by the way, how am I doing with my research?"
Yes, this is a fine question to ask, although I might phrase is slightly differently:
"How happy are you with the progress that I am making?"
which makes it a little more open-ended and focuses the question more on process and progress.
I would also agree that it's fine (even good) to ask this question, but I would suggest not throwing it out at the end of the meeting, which may lead your advisor to just give a perfunctory response - for example saying that everything is fine even if s/he has concerns because they have another meeting about to start...
Instead it might be better to bring it up at the beginning of the meeting or even before the meeting in an email, which would allow your advisor to give you a more considered (and hopefully useful) response.
I think it's fine to ask this question. It's perfectly reasonable to be interested in getting feedback from your advisor. Most advisors should be okay with this kind of question as it shows a high level of interest and willingness to improve. However, I agree that you could frame your question differently. You could ask if your advisor has any feedback on your progress or if there are any areas where you need to put in more effort.
First, I think it is very easy for PhD students to err wildly (from the viewpoint of the advisor and/or more senior professionals) in all possible directions in their self-appraisal, if for no other reason than having no perspective or prior experience (and friends and peers in similar no-perspective/experience situations).
And, then, answers to the question may vary enormously depending on the precise wording. E.g., "Are you happy with my progress?" might tend to invite reassurance rather than critique. I think it is misguided to ask "Should I be working harder?", since in too many cases over-the-top "effort" ends up being seriously misdirected and only serves to exhaust you. Perhaps "How would you appraise my progress thus far?" if you really want some constructive criticism (and asked at the beginning of your meeting, rather than end).