Check `isdiag` in dense trig functions (#56483)
This improves performance for dense diagonal matrices, as we may apply
the function only to the diagonal elements.
```julia
julia> A = diagm(0=>rand(100));
julia> @btime cos($A);
349.211 μs (22 allocations: 401.58 KiB) # nightly v"1.12.0-DEV.1571"
16.215 μs (7 allocations: 80.02 KiB) # this PR
```
---------
Co-authored-by: Daniel Karrasch <daniel.karrasch@posteo.de>