Swearing that you will follow the laws of a country is an example of giving allegiance.
Always defending your friend and looking out for his best interests is an example of allegiance to your friend.
Origin of allegiance
- Middle English alligeaunce alteration of ligeaunce from Old French ligeance from lige liege liege
From American Heritage Dictionary of the English Language, 5th Edition