You have to describe your action as if you were performing it at that time.
The only difference between a readied action and an immediately-taken action is when it occurs. The former occurs at a defined trigger, while the latter occurs immediately.
The rules for the Ready action state:
you choose the action you will take in response to that trigger, or you choose to move up to your speed in response to it.
The wording isn't as clear as it should be, but the word "action" here does not refer to selection among the different types of action, but what the actual action is.
This is supported by the additional guidance for a readied action:
When you ready a spell, you cast it as normal but hold its energy, which you release with your reaction when the trigger occurs.
It would not make logical sense to require spellcasters to decide when readying their "Cast A Spell" action which spell they are going to cast, but to not require melee fighters exactly what kind of attack they will be using when they use the "Attack" action.
Thus the logical conclusion is that regardless of action type, the exact action to be taken must be decided ahead of time.
Looking at the specific example in the question:
could you just say "I Ready an attack, if any of the creatures move close to us?" and then, when it is triggered, decide which weapon to attack with, whether to attack with melee or range
What is "close to us" here? That's not a suitable trigger. Your trigger needs to be stated precisely enough for your DM to unequivocally know when the readied action will actually happen. So at a minimum, you need to specify a distance, not just "close". If this distance is outside of melee range, then you've obviously decided ahead of time to use a ranged attack. If it's inside melee range, you could argue that either a melee or ranged attack could be used, but it's unlikely that you would have meant a ranged attack in that case. More likely is that you've also in that case decided ahead of time to use a melee attack.
Note also that the examples given in the text — "…pull the lever that opens it" and "…move away" — are specific things one does. You can't just say "I'm going to interact with an object", or "I'm going to move" (which could be to the other side of the enemy, or it could be away from it). You have to say exactly how you are going to do those things.
All that said, I would not think it too terribly unbalancing should the DM decide that a less-specific statement is allowed. Assuming the NPCs are given the same degree of leeway so that both sides of a fight are playing by the same rules, I doubt that the outcome of combat would be affected much, if at all, by broadening the rule in this respect.