Yes, that's totally ok, as long as you're really sure you're not cutting away anything that might be relevant to the solution.
For many people, having their stuff edited (especially when it's a massive edit) feels unusual and invasive at first. They tend to get angry and defensive, to the point of an edit war, even if your edit makes the question objectively better.
To avoid this, be as nice about it as possible: avoid using words like "fluff" when describing the content you removed; also consider leaving a comment explaining to the user what you did and why, something like
Hi! I edited your question and removed some bits that I think aren't directly connected with the issue at hand. If I accidentally removed something that is essential to your core question, feel free to edit again!