For binary classification task you can use any of these layers as a final layer.
Dense(1, activation=“sigmoid”) will produce one value.
Dense(2, activation=“softmax”) will produce two values, which are probabilities of belonging to two classes.
To get the respective class out of the two values produced by the model, you can use np.argmax(predicted_y).
Loss functions in these two cases should be different: in the first example - binary cross entropy, in the second example - categorical cross entropy.
If you pass targets to the model as two column matrix (one hot encoded classes), use categorical cross entropy. If you pass them as one column with 0 and 1 values, use sparse categorical cross entropy.