Was Austria justified in giving the ultimatum to Serbia before WWI?
No, the Austrians were not justified. At least, they were not justified in giving that particular ultimatum with those particular terms. The ultimatum showed that what they really wanted was war.
The part of the ultimatum that was so unacceptable was one that required Serbia to allow Austrians come into their country and conduct the investigation of the assassination of the Archduke. There was no way that Serbia could allow an enemy country to have that kind of power. It would simply be too humiliating and it would be a loss of Serbian independence.
Because Austria made such unacceptable demands, they were not justified in giving that particular ultimatum to Serbia.