The answer to that question depends on what is stated in the CC&R documents that govern how the HOA is to be run. Normally, an HOA might have the right to come on to the property to inspect for a violation of the development’s rules or regulations. This is allowed only if the HOA has good reason to believe a violation is occurring.
If the HOA enters on to your unit with just cause, then, yes, it risks liability for trespass. Also, notice to the owner is typically required before any entrance to inspect for a rule violation. The HOA governing documents usually say something about what type of notice the HOAs must give. The courts commonly require that HOAs provide an owner with “reasonable” notice as per any given circumstance.
If you believe they entered in violation of the terms of the governing documents, you might have a legal case against the HOA for trespass. Also, the HOA might be liable for a breach of fiduciary duty if it acts in a discriminatory manner based on race, religion, etc. Also, selective enforcement is not permitted and is often an indication of discrimination or a personal ax to grind by an officer in the HOA. An HOA has a fiduciary duty to act in the best interest of all the development’s homeowners and to enforce all the rules and restrictions fairly.
Yes, you can put a no trespassing sign and if they are only enforcing the rules against you and not others you can defend on the grounds of selective enforcement. You may want to take dated picture from the street of others who have garden animals.