Passivity is not closely related to aspect or tense. It has different rules/conventions to follow depending on aspect and tense, but it does not affect which is used terribly much.
So, let's look at passive constructions using the verb to write. Let's start with the present progressive (why we start there should become clear shortly):
I am writing the book
This becomes, in the passive,
The book is being written by me
Okay, so how about the simple past:
You wrote the book
The book was written by you
And then the present perfect:
She has written the book
The book has been written by her
We can see that, generally speaking, we put the verb in its past participle form, regardless of the original tense or aspect. The tense and aspect are then transferred to the auxiliary verb, to be.
So, how about the simple present?
I write the book
The book is written by me
Now we run into a potential confusion. "Written by" has also, as well as generally showing up in passive forms of to write, become something of a set phrase. We might talk about "a book written by a former slave". We can think of that as a prepositional phrase from which some words have been elided, "a book that was written by a former slave", and how that works grammatically is clear. However, the fact that it suffers from such ellipsis on a regular basis means that we don't habitually treat it as a prepositional phrase, and see "written by X" as an adjectival phrase. We might see the bare phrase "written by children" on a book, to provide information. As such, "X is written by Y" might be parsed as the passive of "Y writes X", but it can also be parsed an adjective with the effective meaning that "Y wrote X". To avoid potential confusion, "I write the book" will sometimes be rendered passive as "the book is being written by me". The same confusion will not occur if the thing someone writes is not a specific work, of course. There is no problem passivising "Bob writes music" as "music is written by Bob".
(This is also likely related to the fact that written in an adjective in its own right - "written evidence", "written submission", "written work"; there are plenty of adjectives that descend in this way from a past participle.)
So, "Shakespeare wrote Hamlet" passivises nicely to:
Hamlet was written by Shakespeare
That is a statement about things that happened. However, you will also come across
Hamlet is written by Shakespeare
That is not, as it might appear, a passivisation of "Shakespeare writes Hamlet" (well, it could be, on a timeline perhaps - where the present historical is common - but otherwise it's not). It is, instead, a description of Hamlet, describing one of its attributes.
So the proper passive construction is to say that it was written by Shakespeare; the past is appropriate because the writing happened in the past. However, in the sense that the play still exists today, you can say that Hamlet is written by Shakespeare. However, in that case it is not a passive form of to write, but simply using the verb to be with an adjectival phrase.