You can wear whatever you like, however if it were me I'd wear a dress or a skirt. Depending on the dress code as to how formal I'd go. If there's no dress code & you can't ask them, go by how formal the invite is.
If my DH were groomsman, I'd go a little more formal than normal, sober could get some nice photos together.
You could go a short heel, or even a heel for photos & take flats?
My cousin is having a garden wedding & I have a knee length black lace dress. I want to find hot pink heels, but I'll also take flats or thongs rather than bare feet. LOL