Vanilla Doom secrets are always sectors with the sector special 9. Boom added a "secret flag" in the sector special allowing to combine it with other effects by adding the value 128 to said other effect. In UDMF and Hexen format, the secret flag for sectors is instead 1024, this change was required to support more sector special types.
More recently was added the ability to mark things as secret in UDMF by setting its "countsecret" spawn flag to true. It is also possible, but not advised, to give actors the COUNTSECRET flag, which will make them always secret wherever they are placed. Things marked as secret with either of these methods will be found when picked up; so only inventory actors should ever be flagged as secret.
Sector-based secrets are counted/triggered when the player is standing on the ground in the intended sector. Flying over the sector but not landing on the ground doesn't seem to trigger their discovery and give the player credit, so keep this in mind as you either build maps or play them.
A SECRETS lump can be provided in a mod to help find secrets. The secret console command will list the secrets declared for this level in this lump, if any, and will also color-code those found in green and in red those not found.