On behalf of my advisor, I recently wrote a grant to obtain some specialized and expensive hardware. Is it ok to mention this on my CV, even though the grant is in my advisor's name and if yes, what would be a good way to word it ?
You can list on your CV whatever you think is useful information for the reader. In your case, whether something is useful depends on what your position in life is. If you're a full professor with a long history of funded research, what you describe is likely not useful to list on a CV. If you're a graduate student with an otherwise relatively short CV, then that's a different story. I would suggest wording such as
Co-authored the proposal for grant XY-1234-5678 (PI: Professor Z).
Now, whether an entry such as this has any impact is a different issue, but it is certainly not going to hurt.
I would list all relevant grant activity on your CV. Grant activity is something that many departments consider when considered people for academic appointments and it's often missing or hard to see.
It is completely normal for graduate students to apply for grants with their advisors listed as PIs. Be honest about your role and about your advisors leadership role (I like Wolfgan Bangerth's suggestion for wording) but do go ahead and include it.
Bangerth is right that this kind of thing will be less useful for individuals further on in their career but I think it should still be included because it is relevant and it makes your CV a more complete record of your academic activity.
I wouldn't put this on a CV, but it is something that you should bring up during an interview as an example of your experience with the grant writing process.
To elaborate on this:
An individual is either a PI/Co-PI on a grant or they aren't. Some readers might read your CV and think that you're claiming undue credit.
In recent months I've interviewed many candidates for a faculty position. Some of them had helped to write grant proposals in this way (and we would discuss this in an interview), but they didn't put those grants on their CV. Other candidates had submitted proposals as a PI/Co-PI, and they appropriately included this information on their CV's along with whether or not the grant was pending or had actually been funded. Listing proposals that were not funded is not something that I've seen on CV's that I've reviewed.