Do they have this authority?
Basically, the United Nations usually issues resolutions that express their opinions formally and is the organisation's primary way to get members states to take action. Most resolutions are issued by the General Assembly or the Security Council.
Resolutions issued by the UNSC are considered binding as stated in Article 25 of the United Nations Charter:
The Members of the United Nations agree to accept and carry out the decisions of the Security Council in accordance with the present Charter.
However, resolutions issued by the General Assembly are not. A UN FAQ states that "The nature of the resolution determines if it is considered binding on States." and Articles 10 and 14 of the UN Charter describes resolutions issued by the General Assembly as "recommendations", implying that they are non-binding.
Regardless of whether it is binding or not, the UN does not have many choices in the event of countries disobeying the resolutions, other than implementing sanctions on those countries.
One such example is North Korea, which the UN issued many resolutions strengthening sanctions against the regime and condemning the country's nuclear test. However, it does not stop DPRK from conducting further tests. This shows that it is difficult for the UN to enforce resolutions if member states do not comply.
Is there any document or something the countries have signed to give this authority (which constitutes part of their sovereignty) to UN?
Yes, Article 25 of the United Nations Charter, which is relevant to resolutions issued by the UNSC, is agreed by all UN member states. As for resolutions issued by the General Assembly, they are considered to be recommendations, as seen in Chapter IV of the Charter.
The Charter is a constituent treaty so all members states are bound by its articles.
If there is a document or something signed by the countries, how can it be changed?
The UN Charter has to be amended to change the rules. Article 108 of the United Nations Charter states that amendments require the consent of all the permanent members of UNSC and the agreement of 2/3 of member states.
Also, the UN Charter has been amended 5 times in the past.
Amendments to the present Charter shall come into force for all Members of the United Nations when they have been adopted by a vote of two thirds of the members of the General Assembly and ratified in accordance with their respective constitutional processes by two thirds of the Members of the United Nations, including all the permanent members of the Security Council.