Provided you use a cryptographically secure hash function, then yes, this is secure. This is because any attempt to modify the additional data would modify the hash with high probability, and if the hash were modified, the tag would fail to verify with high probability. It can be thought of somewhat related to a Merkle tree. SHA-2, SHA-3, and BLAKE2 are all fine options here; MD5 and SHA-1 are not.
In many AEADs, the associated data portion is online, just like the encrypted portion, so assuming the library interface is suitable, you shouldn't need to do this. However, not all library interfaces allow streaming additional data, and some AEADs (e.g., CCM) are not online at all, and so this can be useful if you need a very large or unknown amount of additional data.
Note that if you have a small amount of fixed additional data, such as a packet header, you can also pass that data, followed by a hash of the large quantity of data, as the AEAD's additional data, if that's more convenient. However, to avoid attacks where the attacker moves data between the hash and the packet header, you must always use the hash, even if the "large" quantity of data is empty, and use the same hash algorithm with the same size output.
In general, it's important to note whenever your additional data contains multiple segments that you must avoid cases where the attacker can confuse which part is which or move data between the parts, such as by prefixing each segment with a 4- or 8-byte length of its segment, or always using fixed-length data segments. This is true whether you pass the AD to a hash algorithm or use it directly in the AEAD.