I went to the Supreme Court less than 5 hours ago and while I was there I took a photo of the accused. Can I be arrested or prosecuted if no one saw me take the photo?
If there is proof that you took the photo, you can be prosecuted whether someone saw you take it or not. Generally, any form of recording device (including cameras) are prohibited in a courtroom without the leave of the Court or the Registrar.
Are you planning on publishing the picture in any form and or sharing/ selling it so that it winds up in public domain somewhere, somehow? Because that is what will attract the courts attention quick smart, and they will definitely come after you.