Map<ID, Contact> m = new Map<ID, Contact>([SELECT Id, LastName FROM Contact]);
But you can also achieve this if you are using database.query() to run the select.This can be achieved like follows :
String query = '
SELECT Id, LastName FROM Contact';Map<id,Contact> mapCon = new Map<id,Contact>((List<Contact>)Database.query(query));